Skip to content

Commit edc3031

Browse files
authored
Merge branch 'master' into IndexType
2 parents 44ffe01 + 42b5350 commit edc3031

File tree

10 files changed

+41
-3
lines changed

10 files changed

+41
-3
lines changed

cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ function(_report_sdk prefix)
2222
message(STATUS " Triple name: ${SWIFT_SDK_${prefix}_TRIPLE_NAME}")
2323
message(STATUS " Architectures: ${SWIFT_SDK_${prefix}_ARCHITECTURES}")
2424
message(STATUS " Object Format: ${SWIFT_SDK_${prefix}_OBJECT_FORMAT}")
25+
foreach(arch ${SWIFT_SDK_${prefix}_ARCHITECTURES})
26+
if(${SWIFT_SDK_${prefix}_ARCH_${arch}_LINKER})
27+
message(STATUS " Linker (${arch}): ${SWIFT_SDK_${prefix}_ARCH_${arch}_LINKER}")
28+
else()
29+
message(STATUS " Linker (${arch}): ${CMAKE_LINKER}")
30+
endif()
31+
endforeach()
2532

2633
foreach(arch ${SWIFT_SDK_${prefix}_ARCHITECTURES})
2734
message(STATUS

docs/HighLevelSILOptimizations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,11 @@ sil.never
349349
@_semantics("optimize.sil.never")
350350
func miscompile() { ... }
351351

352+
sil.specialize.generic.never
353+
354+
The sil optimizer should never create generic specializations of this function.
355+
356+
352357
Availability checks
353358
~~~~~~~~~~~~~~~~~~~
354359

include/swift/AST/TypeRepr.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ class SimpleIdentTypeRepr : public ComponentIdentTypeRepr {
283283
SimpleIdentTypeRepr(SourceLoc Loc, Identifier Id)
284284
: ComponentIdentTypeRepr(TypeReprKind::SimpleIdent, Loc, Id) {}
285285

286+
SimpleIdentTypeRepr(const SimpleIdentTypeRepr &repr)
287+
: SimpleIdentTypeRepr(repr.getLoc(), repr.getIdentifier()) {}
288+
286289
static bool classof(const TypeRepr *T) {
287290
return T->getKind() == TypeReprKind::SimpleIdent;
288291
}
@@ -846,6 +849,9 @@ class FixedTypeRepr : public TypeRepr {
846849
FixedTypeRepr(Type Ty, SourceLoc Loc)
847850
: TypeRepr(TypeReprKind::Fixed), Ty(Ty), Loc(Loc) {}
848851

852+
FixedTypeRepr(const FixedTypeRepr& repr)
853+
: FixedTypeRepr(repr.Ty, repr.Loc) {}
854+
849855
/// Retrieve the location.
850856
SourceLoc getLoc() const { return Loc; }
851857

include/swift/Remote/MetadataReader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,8 @@ class MetadataReader {
869869
return {true, metadataPointer};
870870
}
871871
}
872+
873+
swift_runtime_unreachable("Unhandled IsaEncodingKind in switch.");
872874
}
873875

874876
/// Read the parent type metadata from a nested nominal type metadata.

lib/Basic/Demangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,7 @@ NodePointer Demangler::demangleFuncSpecParam(Node::IndexType ParamIdx) {
14121412
// The parameters will be added later.
14131413
return addChild(Param, createNode(
14141414
Node::Kind::FunctionSignatureSpecializationParamKind,
1415-
unsigned(FunctionSigSpecializationParamKind::ClosureProp)));
1415+
uint64_t(FunctionSigSpecializationParamKind::ClosureProp)));
14161416
case 'p': {
14171417
switch (nextChar()) {
14181418
case 'f':

lib/SILOptimizer/Transforms/PerformanceInliner.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,10 @@ static Optional<bool> shouldInlineGeneric(FullApplySite AI) {
547547
(ModuleName == STDLIB_NAME || ModuleName == SWIFT_ONONE_SUPPORT))
548548
return false;
549549

550+
// Do not inline into thunks.
551+
if (AI.getFunction()->isThunk())
552+
return false;
553+
550554
// Always inline generic functions which are marked as
551555
// AlwaysInline or transparent.
552556
if (Callee->getInlineStrategy() == AlwaysInline || Callee->isTransparent())

lib/SILOptimizer/Utils/Generics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ static unsigned getBoundGenericDepth(Type t) {
5252
// Initialize SpecializedType iff the specialization is allowed.
5353
ReabstractionInfo::ReabstractionInfo(ApplySite Apply, SILFunction *OrigF,
5454
SubstitutionList ParamSubs) {
55-
if (!OrigF->shouldOptimize()) {
55+
if (!OrigF->shouldOptimize() ||
56+
OrigF->hasSemanticsAttr("optimize.sil.specialize.generic.never")) {
5657
DEBUG(llvm::dbgs() << " Cannot specialize function " << OrigF->getName()
5758
<< " marked to be excluded from optimizations.\n");
5859
return;

stdlib/public/core/Dump.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
/// Dumps an object's contents using its mirror to the specified output stream.
1414
@discardableResult
15+
@_semantics("optimize.sil.specialize.generic.never")
1516
public func dump<T, TargetStream : TextOutputStream>(
1617
_ value: T,
1718
to target: inout TargetStream,
@@ -37,6 +38,7 @@ public func dump<T, TargetStream : TextOutputStream>(
3738

3839
/// Dumps an object's contents using its mirror to standard output.
3940
@discardableResult
41+
@_semantics("optimize.sil.specialize.generic.never")
4042
public func dump<T>(
4143
_ value: T,
4244
name: String? = nil,
@@ -55,6 +57,7 @@ public func dump<T>(
5557
}
5658

5759
/// Dump an object's contents. User code should use dump().
60+
@_semantics("optimize.sil.specialize.generic.never")
5861
internal func _dump_unlocked<TargetStream : TextOutputStream>(
5962
_ value: Any,
6063
to target: inout TargetStream,
@@ -153,6 +156,7 @@ internal func _dump_unlocked<TargetStream : TextOutputStream>(
153156

154157
/// Dump information about an object's superclass, given a mirror reflecting
155158
/// that superclass.
159+
@_semantics("optimize.sil.specialize.generic.never")
156160
internal func _dumpSuperclass_unlocked<TargetStream : TextOutputStream>(
157161
mirror: Mirror,
158162
to target: inout TargetStream,

stdlib/public/core/OutputStream.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ func _getEnumCaseName<T>(_ value: T) -> UnsafePointer<CChar>?
250250
func _opaqueSummary(_ metadata: Any.Type) -> UnsafePointer<CChar>?
251251

252252
/// Do our best to print a value that cannot be printed directly.
253+
@_semantics("optimize.sil.specialize.generic.never")
253254
internal func _adHocPrint_unlocked<T, TargetStream : TextOutputStream>(
254255
_ value: T, _ mirror: Mirror, _ target: inout TargetStream,
255256
isDebugPrint: Bool
@@ -344,6 +345,7 @@ internal func _adHocPrint_unlocked<T, TargetStream : TextOutputStream>(
344345
}
345346

346347
@inline(never)
348+
@_semantics("optimize.sil.specialize.generic.never")
347349
@_semantics("stdlib_binary_only")
348350
internal func _print_unlocked<T, TargetStream : TextOutputStream>(
349351
_ value: T, _ target: inout TargetStream
@@ -400,6 +402,7 @@ func _toStringReadOnlyPrintable<T : CustomStringConvertible>(_ x: T) -> String {
400402
// `debugPrint`
401403
//===----------------------------------------------------------------------===//
402404

405+
@_semantics("optimize.sil.specialize.generic.never")
403406
@inline(never)
404407
public func _debugPrint_unlocked<T, TargetStream : TextOutputStream>(
405408
_ value: T, _ target: inout TargetStream
@@ -423,6 +426,7 @@ public func _debugPrint_unlocked<T, TargetStream : TextOutputStream>(
423426
_adHocPrint_unlocked(value, mirror, &target, isDebugPrint: true)
424427
}
425428

429+
@_semantics("optimize.sil.specialize.generic.never")
426430
internal func _dumpPrint_unlocked<T, TargetStream : TextOutputStream>(
427431
_ value: T, _ mirror: Mirror, _ target: inout TargetStream
428432
) {

stdlib/public/runtime/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,15 @@ foreach(sdk ${ELFISH_SDKS})
164164
set(section_magic_begin_obj "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/section_magic_begin-${arch_suffix}.dir/swift_sections.S${CMAKE_C_OUTPUT_EXTENSION}")
165165
set(section_magic_end_obj "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/section_magic_end-${arch_suffix}.dir/swift_sections.S${CMAKE_C_OUTPUT_EXTENSION}")
166166

167+
set(ld_EXECUTABLE ${CMAKE_LINKER})
168+
if(${SWIFT_SDK_${prefix}_ARCH_${arch}_LINKER})
169+
set(ld_EXECUTABLE ${SWIFT_SDK_${prefix}_ARCH_${arch}_LINKER})
170+
endif()
171+
167172
add_custom_command_target(section_magic_${arch_suffix}_begin_object
168173
COMMAND
169174
# Merge ImageInspectionInit.o + swift_sections.S(BEGIN) => swift_begin.o
170-
${CMAKE_LINKER} -r -o "${SWIFTLIB_DIR}/${arch_subdir}/swift_begin.o"
175+
${ld_EXECUTABLE} -r -o "${SWIFTLIB_DIR}/${arch_subdir}/swift_begin.o"
171176
"${section_magic_begin_obj}" "${section_magic_loader_obj}"
172177
OUTPUT
173178
"${SWIFTLIB_DIR}/${arch_subdir}/swift_begin.o"

0 commit comments

Comments
 (0)