Skip to content

Commit a433ebe

Browse files
committed
---
yaml --- r: 347135 b: refs/heads/master c: 490a265 h: refs/heads/master i: 347133: a16518b 347131: feeaeaa 347127: 2b55d6a 347119: 556d8a9 347103: 538e4b3 347071: fc89d8f 347007: 0c85520 346879: 2cbf856 346623: c66eaba 346111: f0a47f1
1 parent 4b7effa commit a433ebe

File tree

6 files changed

+118
-54
lines changed

6 files changed

+118
-54
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 5a8f2b1836c18673cb2634f91d0377f2a6da0cb7
2+
refs/heads/master: 490a26542b23bfe94e99110b81032993d22ea268
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/CMakeLists.txt

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,6 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
101101
message(STATUS "No build type was specified, will default to ${CMAKE_BUILD_TYPE}")
102102
endif()
103103

104-
set(SWIFT_STDLIB_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
105-
"Build type for the Swift standard library and SDK overlays [Debug, RelWithDebInfo, Release, MinSizeRel]")
106-
set_property(CACHE SWIFT_STDLIB_BUILD_TYPE PROPERTY
107-
STRINGS "Debug" "RelWithDebInfo" "Release" "MinSizeRel")
108-
109-
is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" swift_optimized)
110-
if(swift_optimized)
111-
set(SWIFT_STDLIB_ASSERTIONS_default FALSE)
112-
else()
113-
set(SWIFT_STDLIB_ASSERTIONS_default TRUE)
114-
endif()
115-
option(SWIFT_STDLIB_ASSERTIONS
116-
"Enable internal checks for the Swift standard library (useful for debugging the library itself, does not affect checks required for safety)"
117-
"${SWIFT_STDLIB_ASSERTIONS_default}")
118-
119-
option(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER
120-
"Use the host compiler and not the internal clang to build the swift runtime"
121-
FALSE)
122-
123104
set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
124105
"Build Swift with code coverage instrumenting enabled [FALSE, NOT-MERGED, MERGED]")
125106
set_property(CACHE SWIFT_ANALYZE_CODE_COVERAGE PROPERTY
@@ -146,23 +127,6 @@ set(SWIFT_ENABLE_LLD_LINKER TRUE CACHE BOOL
146127
set(SWIFT_ENABLE_GOLD_LINKER TRUE CACHE BOOL
147128
"Enable using the gold linker when available")
148129

149-
set(SWIFT_SDKS "" CACHE STRING
150-
"If non-empty, limits building target binaries only to specified SDKs (despite other SDKs being available)")
151-
152-
set(SWIFT_PRIMARY_VARIANT_SDK "" CACHE STRING
153-
"Primary SDK for target binaries")
154-
set(SWIFT_PRIMARY_VARIANT_ARCH "" CACHE STRING
155-
"Primary arch for target binaries")
156-
157-
set(SWIFT_NATIVE_LLVM_TOOLS_PATH "" CACHE STRING
158-
"Path to the directory that contains LLVM tools that are executable on the build machine")
159-
160-
set(SWIFT_NATIVE_CLANG_TOOLS_PATH "" CACHE STRING
161-
"Path to the directory that contains Clang tools that are executable on the build machine")
162-
163-
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "" CACHE STRING
164-
"Path to the directory that contains Swift tools that are executable on the build machine")
165-
166130
set(SWIFT_TOOLS_ENABLE_LTO OFF CACHE STRING "Build Swift tools with LTO. One
167131
must specify the form of LTO by setting this to one of: 'full', 'thin'. This
168132
option only affects the tools that run on the host (the compiler), and has
@@ -176,10 +140,6 @@ option(SWIFT_FORCE_OPTIMIZED_TYPECHECKER "Override the optimization setting of
176140
the type checker so that it always compiles with optimization. This eases
177141
debugging after type checking occurs by speeding up type checking" FALSE)
178142

179-
option(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES
180-
"Generate .swiftinterface files alongside .swiftmodule files"
181-
TRUE)
182-
183143
# Allow building Swift with Clang's Profile Guided Optimization
184144
if(SWIFT_PROFDATA_FILE AND EXISTS ${SWIFT_PROFDATA_FILE})
185145
if(NOT CMAKE_C_COMPILER_ID MATCHES Clang)
@@ -188,6 +148,57 @@ if(SWIFT_PROFDATA_FILE AND EXISTS ${SWIFT_PROFDATA_FILE})
188148
add_definitions("-fprofile-instr-use=${SWIFT_PROFDATA_FILE}")
189149
endif()
190150

151+
#
152+
# User-configurable Swift Standard Library specific options.
153+
#
154+
# TODO: Once the stdlib/compiler builds are split, this should be sunk into the
155+
# stdlib cmake.
156+
#
157+
158+
set(SWIFT_STDLIB_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
159+
"Build type for the Swift standard library and SDK overlays [Debug, RelWithDebInfo, Release, MinSizeRel]")
160+
set_property(CACHE SWIFT_STDLIB_BUILD_TYPE PROPERTY
161+
STRINGS "Debug" "RelWithDebInfo" "Release" "MinSizeRel")
162+
163+
is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" swift_optimized)
164+
if(swift_optimized)
165+
set(SWIFT_STDLIB_ASSERTIONS_default FALSE)
166+
else()
167+
set(SWIFT_STDLIB_ASSERTIONS_default TRUE)
168+
endif()
169+
option(SWIFT_STDLIB_ASSERTIONS
170+
"Enable internal checks for the Swift standard library (useful for debugging the library itself, does not affect checks required for safety)"
171+
"${SWIFT_STDLIB_ASSERTIONS_default}")
172+
173+
option(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER
174+
"Use the host compiler and not the internal clang to build the swift runtime"
175+
FALSE)
176+
177+
set(SWIFT_SDKS "" CACHE STRING
178+
"If non-empty, limits building target binaries only to specified SDKs (despite other SDKs being available)")
179+
180+
set(SWIFT_PRIMARY_VARIANT_SDK "" CACHE STRING
181+
"Primary SDK for target binaries")
182+
set(SWIFT_PRIMARY_VARIANT_ARCH "" CACHE STRING
183+
"Primary arch for target binaries")
184+
185+
set(SWIFT_NATIVE_LLVM_TOOLS_PATH "" CACHE STRING
186+
"Path to the directory that contains LLVM tools that are executable on the build machine")
187+
188+
set(SWIFT_NATIVE_CLANG_TOOLS_PATH "" CACHE STRING
189+
"Path to the directory that contains Clang tools that are executable on the build machine")
190+
191+
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "" CACHE STRING
192+
"Path to the directory that contains Swift tools that are executable on the build machine")
193+
194+
option(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES
195+
"Generate .swiftinterface files alongside .swiftmodule files"
196+
TRUE)
197+
198+
option(SWIFT_STDLIB_ENABLE_SIB_TARGETS
199+
"Should we generate sib targets for the stdlib or not?"
200+
FALSE)
201+
191202
#
192203
# User-configurable Android specific options.
193204
#

trunk/lib/IRGen/GenMeta.cpp

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,18 +205,21 @@ static void emitMetadataCompletionFunction(IRGenModule &IGM,
205205
IGF.Builder.CreateRet(returnValue);
206206
}
207207

208-
static bool needsForeignMetadataCompletionFunction(StructDecl *decl) {
208+
static bool needsForeignMetadataCompletionFunction(IRGenModule &IGM,
209+
StructDecl *decl) {
209210
// Currently, foreign structs never need a completion function.
210211
return false;
211212
}
212213

213-
static bool needsForeignMetadataCompletionFunction(EnumDecl *decl) {
214+
static bool needsForeignMetadataCompletionFunction(IRGenModule &IGM,
215+
EnumDecl *decl) {
214216
// Currently, foreign enums never need a completion function.
215217
return false;
216218
}
217219

218-
static bool needsForeignMetadataCompletionFunction(ClassDecl *decl) {
219-
return decl->hasSuperclass();
220+
static bool needsForeignMetadataCompletionFunction(IRGenModule &IGM,
221+
ClassDecl *decl) {
222+
return IGM.getOptions().LazyInitializeClassMetadata || decl->hasSuperclass();
220223
}
221224

222225
/*****************************************************************************/
@@ -1171,7 +1174,7 @@ namespace {
11711174
}
11721175

11731176
bool needsForeignMetadataCompletionFunction() {
1174-
return ::needsForeignMetadataCompletionFunction(Type);
1177+
return ::needsForeignMetadataCompletionFunction(IGM, Type);
11751178
}
11761179

11771180
/// Add an SingletonMetadataInitialization structure to the descriptor.
@@ -3804,7 +3807,7 @@ namespace {
38043807
}
38053808

38063809
bool needsMetadataCompletionFunction() {
3807-
return needsForeignMetadataCompletionFunction(Target);
3810+
return needsForeignMetadataCompletionFunction(IGM, Target);
38083811
}
38093812

38103813
void createMetadataCompletionFunction() {
@@ -3837,10 +3840,19 @@ namespace {
38373840
public:
38383841
ForeignClassMetadataBuilder(IRGenModule &IGM, ClassDecl *target,
38393842
ConstantStructBuilder &B)
3840-
: ForeignMetadataBuilderBase(IGM, target, B) {}
3843+
: ForeignMetadataBuilderBase(IGM, target, B) {
3844+
if (IGM.getOptions().LazyInitializeClassMetadata)
3845+
CanBeConstant = false;
3846+
}
38413847

38423848
void emitInitializeMetadata(IRGenFunction &IGF, llvm::Value *metadata,
38433849
MetadataDependencyCollector *collector) {
3850+
if (!Target->hasSuperclass()) {
3851+
assert(IGM.getOptions().LazyInitializeClassMetadata &&
3852+
"should have superclass if not lazy initializing class metadata");
3853+
return;
3854+
}
3855+
38443856
// Emit a reference to the superclass.
38453857
auto superclass = IGF.emitAbstractTypeMetadataRef(
38463858
Target->getSuperclass()->getCanonicalType());
@@ -3858,6 +3870,24 @@ namespace {
38583870
// Visitor methods.
38593871

38603872
void addValueWitnessTable() {
3873+
// The runtime will fill in the default VWT during allocation for the
3874+
// foreign class metadata.
3875+
//
3876+
// As of Swift 5.1, the runtime will fill in a default VWT during
3877+
// allocation of foreign class metadata. We rely on this for correctness
3878+
// on COFF, where we can't necessarily reference the stanard VWT from the
3879+
// metadata candidate, but it is a good optimization everywhere.
3880+
//
3881+
// The default VWT uses ObjC-compatible reference counting if ObjC interop
3882+
// is enabled and Swift-compatible reference counting otherwise. That is
3883+
// currently always good enough for foreign classes, so we can
3884+
// unconditionally rely on the default VWT.
3885+
//
3886+
// FIXME: take advantage of this on other targets when targeting a
3887+
// sufficiently recent runtime.
3888+
if (IGM.getOptions().LazyInitializeClassMetadata)
3889+
return B.addNullPointer(IGM.WitnessTablePtrTy);
3890+
38613891
// Without Objective-C interop, foreign classes must still use
38623892
// Swift native reference counting.
38633893
auto type = (IGM.ObjCInterop

trunk/stdlib/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,11 @@ function(swift_create_stdlib_targets name variant define_all_alias)
102102
endfunction()
103103

104104
swift_create_stdlib_targets("swift-stdlib" "" TRUE)
105-
swift_create_stdlib_targets("swift-stdlib" "sib" TRUE)
106-
swift_create_stdlib_targets("swift-stdlib" "sibopt" TRUE)
107-
swift_create_stdlib_targets("swift-stdlib" "sibgen" TRUE)
105+
if(SWIFT_STDLIB_ENABLE_SIB_TARGETS)
106+
swift_create_stdlib_targets("swift-stdlib" "sib" TRUE)
107+
swift_create_stdlib_targets("swift-stdlib" "sibopt" TRUE)
108+
swift_create_stdlib_targets("swift-stdlib" "sibgen" TRUE)
109+
endif()
108110
swift_create_stdlib_targets("swift-test-stdlib" "" FALSE)
109111

110112
foreach(sdk ${SWIFT_SDKS})

trunk/stdlib/public/runtime/Metadata.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3668,6 +3668,17 @@ class ForeignMetadataCacheEntry
36683668
state = PrivateMetadataState::NonTransitiveComplete;
36693669
}
36703670
} else {
3671+
if (candidate->getValueWitnesses() == nullptr) {
3672+
assert(isa<ForeignClassMetadata>(candidate) &&
3673+
"cannot set default value witnesses for non-class foreign types");
3674+
// Fill in the default VWT if it was not set in the candidate at build
3675+
// time.
3676+
#if SWIFT_OBJC_INTEROP
3677+
candidate->setValueWitnesses(&VALUE_WITNESS_SYM(BO));
3678+
#else
3679+
candidate->setValueWitnesses(&VALUE_WITNESS_SYM(Bo));
3680+
#endif
3681+
}
36713682
state = inferStateForMetadata(candidate);
36723683
}
36733684

trunk/test/IRGen/cf.sil

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %{python} %utils/chex.py < %s > %t/cf.sil
3-
// RUN: %target-swift-frontend -enable-objc-interop -sdk %S/Inputs %t/cf.sil -emit-ir -import-cf-types | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize %t/cf.sil -DINT=i%target-ptrsize
3+
// RUN: %target-swift-frontend -enable-objc-interop -sdk %S/Inputs %t/cf.sil -emit-ir -import-cf-types | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize %t/cf.sil -DINT=i%target-ptrsize -check-prefix CHECK-%target-import-type -check-prefix CHECK-%target-import-type-%target-ptrsize
44

55
// REQUIRES: CPU=i386 || CPU=x86_64
66

@@ -9,7 +9,14 @@
99
// CHECK: [[MUTABLE_REFRIGERATOR:%TSo24CCMutableRefrigeratorRefa]] = type
1010
// CHECK: [[OBJC:%objc_object]] = type
1111

12-
// CHECK: @"$sSo17CCRefrigeratorRefaN" = linkonce_odr hidden constant <{ {{.*}} }> <{ i8** @"$sBOWV", [[INT]] 515, {{.*}}"$sSo17CCRefrigeratorRefaMn", [[TYPE]]* null, i8* null }>
12+
// CHECK: @"$sSo17CCRefrigeratorRefaN" = linkonce_odr hidden
13+
// CHECK-DIRECT-SAME: constant
14+
// CHECK-INDIRECT-SAME: global
15+
// CHECK-SAME: <{ {{.*}} }> <{
16+
// -- value witness table
17+
// CHECK-DIRECT-SAME: i8** @"$sBOWV",
18+
// CHECK-INDIRECT-SAME: i8** null,
19+
// CHECK-SAME: [[INT]] 515, {{.*}}"$sSo17CCRefrigeratorRefaMn", [[TYPE]]* null, i8* null }>
1320

1421
// CHECK: [[MUTABLE_REFRIGERATOR_NAME:@.*]] = private constant [52 x i8] c"CCMutableRefrigerator\00NCCMutableRefrigeratorRef\00St\00\00"
1522

@@ -21,7 +28,10 @@
2128
// CHECK-64-SAME: @"$sSo24CCMutableRefrigeratorRefaMr"
2229

2330
// CHECK-64: @"$sSo24CCMutableRefrigeratorRefaN" = linkonce_odr hidden global <{ {{.*}} }> <{
24-
// CHECK-64-SAME: i8** @"$sBOWV", i64 515, {{.*}}"$sSo24CCMutableRefrigeratorRefaMn", %swift.type* null, i8* null }>
31+
// -- value witness table
32+
// CHECK-DIRECT-64-SAME: i8** @"$sBOWV",
33+
// CHECK-INDIRECT-64-SAME: i8** null,
34+
// CHECK-64-SAME: i64 515, {{.*}}"$sSo24CCMutableRefrigeratorRefaMn", %swift.type* null, i8* null }>
2535

2636
sil_stage canonical
2737

0 commit comments

Comments
 (0)