Skip to content

Commit c4b1010

Browse files
authored
Merge pull request #3808 from swiftwasm/main
2 parents c64b8b9 + dd88e0d commit c4b1010

File tree

74 files changed

+2246
-478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2246
-478
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,12 @@ function(add_libswift name)
743743
744744
get_bootstrapping_path(build_dir ${CMAKE_CURRENT_BINARY_DIR} "${ALS_BOOTSTRAPPING}")
745745
746+
set(sdk_option "")
747+
746748
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
747749
set(deployment_version "10.15") # TODO: once #38675 lands, replace this with
748750
# set(deployment_version "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}")
751+
set(sdk_option "-sdk" "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}")
749752
endif()
750753
get_versioned_target_triple(target ${SWIFT_HOST_VARIANT_SDK}
751754
${SWIFT_HOST_VARIANT_ARCH} "${deployment_version}")
@@ -779,7 +782,7 @@ function(add_libswift name)
779782
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
780783
DEPENDS ${sources} ${deps} ${ALS_DEPENDS}
781784
COMMAND ${ALS_SWIFT_EXEC} "-c" "-o" ${module_obj_file}
782-
"-sdk" "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}"
785+
${sdk_option}
783786
"-target" ${target}
784787
"-module-name" ${module} "-emit-module"
785788
"-emit-module-path" "${build_dir}/${module}.swiftmodule"
@@ -982,8 +985,11 @@ function(add_swift_host_tool executable)
982985
elseif(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING")
983986
# At build time link against the built swift libraries from the
984987
# previous bootstrapping stage.
985-
get_bootstrapping_swift_lib_dir(bs_lib_dir "${ASHT_BOOTSTRAPPING}")
986-
target_link_directories(${executable} PRIVATE ${bs_lib_dir})
988+
if (NOT "${ASHT_BOOTSTRAPPING}" STREQUAL "0")
989+
get_bootstrapping_swift_lib_dir(bs_lib_dir "${ASHT_BOOTSTRAPPING}")
990+
target_link_directories(${executable} PRIVATE ${bs_lib_dir})
991+
target_link_libraries(${executable} PRIVATE "swiftCore")
992+
endif()
987993
988994
# At runtime link against the built swift libraries from the current
989995
# bootstrapping stage.

docs/ReferenceGuides/UnderscoredAttributes.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,3 +625,12 @@ for more details.
625625

626626
Marks a var decl as a variable that must be copied explicitly using the builtin
627627
function Builtin.copy.
628+
629+
## `@_noAllocation`, `@_noLocks`
630+
631+
These attributes are performance annotations. If a function is annotated with
632+
such an attribute, the compiler issues a diagnostic message if the function
633+
calls a runtime function which allocates memory or locks, respectively.
634+
The `@_noLocks` attribute implies `@_noAllocation` because a memory allocation
635+
also locks.
636+

docs/SIL.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,15 @@ Specifies for which types specialized code should be generated.
11071107
sil-function-attribute ::= '[clang "' identifier '"]'
11081108

11091109
The clang node owner.
1110+
::
1111+
1112+
sil-function-attribute ::= '[' performance-constraint ']'
1113+
performance-constraint :: 'no_locks'
1114+
performance-constraint :: 'no_allocation'
1115+
1116+
Specifies the performance constraints for the function, which defines which type
1117+
of runtime functions are allowed to be called from the function.
1118+
11101119

11111120
Basic Blocks
11121121
~~~~~~~~~~~~

include/swift/AST/Attr.def

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,16 @@ SIMPLE_DECL_ATTR(_noImplicitCopy, NoImplicitCopy,
679679
OnVar,
680680
122)
681681

682+
SIMPLE_DECL_ATTR(_noLocks, NoLocks,
683+
OnAbstractFunction | OnSubscript | UserInaccessible |
684+
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
685+
123)
686+
687+
SIMPLE_DECL_ATTR(_noAllocation, NoAllocation,
688+
OnAbstractFunction | OnSubscript | UserInaccessible |
689+
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
690+
124)
691+
682692
// If you're adding a new underscored attribute here, please document it in
683693
// docs/ReferenceGuides/UnderscoredAttributes.md.
684694

include/swift/AST/DiagnosticsSIL.def

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,34 @@ WARNING(warn_dead_weak_store,none,
311311
"weak reference will always be nil because the referenced object is "
312312
"deallocated here", ())
313313

314+
// performance diagnostics
315+
ERROR(performance_annotations_not_enabled,none,
316+
"use -experimental-performance-annotations to enable performance annotations", ())
317+
ERROR(performance_dynamic_casting,none,
318+
"dynamic casting can lock or allocate", ())
319+
ERROR(performance_metadata,none,
320+
"%0 can cause metadata allocation or locks", (StringRef))
321+
ERROR(performance_metadata_type,none,
322+
"Using type %0 can cause metadata allocation or locks", (Type))
323+
ERROR(performance_allocating,none,
324+
"%0 can cause an allocation", (StringRef))
325+
ERROR(performance_deallocating,none,
326+
"%0 can cause an deallocation", (StringRef))
327+
ERROR(performance_deallocating_type,none,
328+
"%0 a value of type %1 can cause a deallocation", (StringRef, Type))
329+
ERROR(performance_locking,none,
330+
"%0 can cause locking", (StringRef))
331+
ERROR(performance_arc,none,
332+
"this code performs reference counting operations which can cause locking", ())
333+
ERROR(performance_objectivec,none,
334+
"calls of Objective-C methods can have unpredictable performance", ())
335+
ERROR(performance_unknown_callees,none,
336+
"called function is not known at compile time and can have unpredictable performance", ())
337+
ERROR(performance_callee_unavailable,none,
338+
"called function is not availbale in this module and can have unpredictable performance", ())
339+
NOTE(performance_called_from,none,
340+
"called from here", ())
341+
314342
// 'transparent' diagnostics
315343
ERROR(circular_transparent,none,
316344
"inlining 'transparent' functions forms circular loop", ())

include/swift/AST/SILOptions.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ class SILOptions {
7878

7979
/// Controls whether cross module optimization is enabled.
8080
bool CrossModuleOptimization = false;
81-
81+
82+
/// Enables experimental performance annotations.
83+
bool EnablePerformanceAnnotations = false;
84+
8285
/// Controls whether or not paranoid verification checks are run.
8386
bool VerifyAll = false;
8487

include/swift/AST/SemanticAttrs.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,7 @@ SEMANTICS_ATTR(OBJC_FORBID_ASSOCIATED_OBJECTS, "objc.forbidAssociatedObjects")
115115

116116
SEMANTICS_ATTR(LIFETIMEMANAGEMENT_MOVE, "lifetimemanagement.move")
117117

118+
SEMANTICS_ATTR(NO_PERFORMANCE_ANALYSIS, "no_performance_analysis")
119+
118120
#undef SEMANTICS_ATTR
119121

include/swift/Option/Options.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,10 @@ def CrossModuleOptimization : Flag<["-"], "cross-module-optimization">,
798798
Flags<[HelpHidden, FrontendOption]>,
799799
HelpText<"Perform cross-module optimization">;
800800

801+
def ExperimentalPerformanceAnnotations : Flag<["-"], "experimental-performance-annotations">,
802+
Flags<[HelpHidden, FrontendOption]>,
803+
HelpText<"Perform cross-module optimization">;
804+
801805
def RemoveRuntimeAsserts : Flag<["-"], "remove-runtime-asserts">,
802806
Flags<[FrontendOption]>,
803807
HelpText<"Remove runtime safety checks.">;
@@ -1278,6 +1282,11 @@ def emit_symbol_graph_dir : Separate<["-"], "emit-symbol-graph-dir">,
12781282
HelpText<"Emit a symbol graph to directory <dir>">,
12791283
MetaVarName<"<dir>">;
12801284

1285+
def symbol_graph_minimum_access_level: Separate<["-"], "symbol-graph-minimum-access-level">,
1286+
Flags<[FrontendOption, NoInteractiveOption, SupplementaryOutput, HelpHidden]>,
1287+
HelpText<"Include symbols with this access level or more when emitting a symbol graph">,
1288+
MetaVarName<"<level>">;
1289+
12811290
def pretty_print: Flag<["-"], "pretty-print">,
12821291
Flags<[SwiftAPIExtractOption, SwiftSymbolGraphExtractOption]>,
12831292
HelpText<"Pretty-print the output JSON">;

include/swift/Reflection/ReflectionContext.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,6 @@ class ReflectionContext
11531153
MetadataAllocation<Runtime> Allocation) {
11541154
if (Allocation.Tag == GenericMetadataCacheTag) {
11551155
struct GenericMetadataCacheEntry {
1156-
StoredPointer Left, Right;
11571156
StoredPointer LockedStorage;
11581157
uint8_t LockedStorageKind;
11591158
uint8_t TrackingInfo;

include/swift/Runtime/RuntimeFnWrappersGen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#ifndef SWIFT_RUNTIME_RUNTIMEFNWRAPPERSGEN_H
1717
#define SWIFT_RUNTIME_RUNTIMEFNWRAPPERSGEN_H
1818

19+
#include "swift/SIL/RuntimeEffect.h"
1920
#include "llvm/IR/Module.h"
2021
#include "llvm/ADT/ArrayRef.h"
2122

0 commit comments

Comments
 (0)