Skip to content

[pull] swiftwasm from main #3808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Oct 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2e47543
[Reflection] Fix ReflectionContext::allocationMetadataPointer.
mikeash Oct 15, 2021
6b5d884
add new flag -symbol-graph-minimum-access-level
QuietMisdreavus Oct 21, 2021
156e58d
use symbol graph opts instead of serialization opts for SGFs
QuietMisdreavus Oct 21, 2021
583a45c
add test for -symbol-graph-minimum-access-level
QuietMisdreavus Oct 21, 2021
86c9407
Add a utility function to Inspector to load the reflection metadata from
aschwaighofer Oct 21, 2021
28b53de
Use the utility function to add the reflection info from loaded images
aschwaighofer Oct 21, 2021
f0c8640
Print whether the metadata is a _ContiguousArrayStorage with a class …
aschwaighofer Oct 21, 2021
3dfede7
Remove fatalError calls
aschwaighofer Oct 28, 2021
8229b37
Performance annotations: add attributes @_noLocks and @_noAllocation
eeckstein Oct 21, 2021
4e6c543
driver/frontend: Add an -experimental-performance-annotations option …
eeckstein Oct 25, 2021
ff2db93
SIL/IRGen: analysis of runtime effects for an instruction
eeckstein Oct 25, 2021
094494e
SILOptimizer: add basic block utilities ReachingReturnBlocks and NonE…
eeckstein Oct 25, 2021
49351c4
SILOptimizer: extract the peephole optimization for Builtin.canBeClas…
eeckstein Oct 25, 2021
7c28d7a
migrate SILInliner to use InstructionDeleter
eeckstein Oct 28, 2021
dc8d482
SILOptimizer: extract predictable access and dead alloc optimizations…
eeckstein Oct 28, 2021
569a520
SILOptimizer: add a mandatory generic-specialization pass.
eeckstein Oct 25, 2021
a5030a6
stdlib: add a _unsafePerformance function which disable performance d…
eeckstein Oct 25, 2021
9f8b155
PerformanceDiagnostics: a pass to print errors for performance violat…
eeckstein Oct 25, 2021
215fbf1
AST: GenericEnvironment::getOrCreateArchetypeFromInterfaceType() need…
slavapestov Oct 28, 2021
b7f6146
Disable moveonly_builtin.swift test
etcwilde Oct 28, 2021
99eadd0
Re-enable VFE/WME tests, take 3, rdar://84643923 (#39955)
kubamracek Oct 29, 2021
d5ae511
Merge pull request #39902 from eeckstein/performance-annotations
eeckstein Oct 29, 2021
1a19d59
Merge pull request #39964 from etcwilde/ewilde/disable-moveonly-built…
etcwilde Oct 29, 2021
78c4c3f
libswift: fixes for the linux bootstrapping build
eeckstein Oct 29, 2021
625d229
Merge pull request #39973 from eeckstein/fix-linux-libswift-bootstrap…
eeckstein Oct 29, 2021
0950626
Merge pull request #39773 from mikeash/fix-allocationmetadatapointer
mikeash Oct 29, 2021
94d824a
Merge pull request #39948 from aschwaighofer/swift-inspect-reflection…
aschwaighofer Oct 29, 2021
646397a
Merge pull request #39965 from slavapestov/parent-of-concrete-is-conc…
slavapestov Oct 29, 2021
dd88e0d
Merge pull request #39865 from apple/QuietMisdreavus/private-swiftc-s…
QuietMisdreavus Oct 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,12 @@ function(add_libswift name)

get_bootstrapping_path(build_dir ${CMAKE_CURRENT_BINARY_DIR} "${ALS_BOOTSTRAPPING}")

set(sdk_option "")

if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
set(deployment_version "10.15") # TODO: once #38675 lands, replace this with
# set(deployment_version "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}")
set(sdk_option "-sdk" "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}")
endif()
get_versioned_target_triple(target ${SWIFT_HOST_VARIANT_SDK}
${SWIFT_HOST_VARIANT_ARCH} "${deployment_version}")
Expand Down Expand Up @@ -777,7 +780,7 @@ function(add_libswift name)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${sources} ${deps} ${ALS_DEPENDS}
COMMAND ${ALS_SWIFT_EXEC} "-c" "-o" ${module_obj_file}
"-sdk" "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}"
${sdk_option}
"-target" ${target}
"-module-name" ${module} "-emit-module"
"-emit-module-path" "${build_dir}/${module}.swiftmodule"
Expand Down Expand Up @@ -980,8 +983,11 @@ function(add_swift_host_tool executable)
elseif(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING")
# At build time link against the built swift libraries from the
# previous bootstrapping stage.
get_bootstrapping_swift_lib_dir(bs_lib_dir "${ASHT_BOOTSTRAPPING}")
target_link_directories(${executable} PRIVATE ${bs_lib_dir})
if (NOT "${ASHT_BOOTSTRAPPING}" STREQUAL "0")
get_bootstrapping_swift_lib_dir(bs_lib_dir "${ASHT_BOOTSTRAPPING}")
target_link_directories(${executable} PRIVATE ${bs_lib_dir})
target_link_libraries(${executable} PRIVATE "swiftCore")
endif()

# At runtime link against the built swift libraries from the current
# bootstrapping stage.
Expand Down
9 changes: 9 additions & 0 deletions docs/ReferenceGuides/UnderscoredAttributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,3 +625,12 @@ for more details.

Marks a var decl as a variable that must be copied explicitly using the builtin
function Builtin.copy.

## `@_noAllocation`, `@_noLocks`

These attributes are performance annotations. If a function is annotated with
such an attribute, the compiler issues a diagnostic message if the function
calls a runtime function which allocates memory or locks, respectively.
The `@_noLocks` attribute implies `@_noAllocation` because a memory allocation
also locks.

9 changes: 9 additions & 0 deletions docs/SIL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,15 @@ Specifies for which types specialized code should be generated.
sil-function-attribute ::= '[clang "' identifier '"]'

The clang node owner.
::

sil-function-attribute ::= '[' performance-constraint ']'
performance-constraint :: 'no_locks'
performance-constraint :: 'no_allocation'

Specifies the performance constraints for the function, which defines which type
of runtime functions are allowed to be called from the function.


Basic Blocks
~~~~~~~~~~~~
Expand Down
10 changes: 10 additions & 0 deletions include/swift/AST/Attr.def
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,16 @@ SIMPLE_DECL_ATTR(_noImplicitCopy, NoImplicitCopy,
OnVar,
122)

SIMPLE_DECL_ATTR(_noLocks, NoLocks,
OnAbstractFunction | OnSubscript | UserInaccessible |
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
123)

SIMPLE_DECL_ATTR(_noAllocation, NoAllocation,
OnAbstractFunction | OnSubscript | UserInaccessible |
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
124)

// If you're adding a new underscored attribute here, please document it in
// docs/ReferenceGuides/UnderscoredAttributes.md.

Expand Down
28 changes: 28 additions & 0 deletions include/swift/AST/DiagnosticsSIL.def
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,34 @@ WARNING(warn_dead_weak_store,none,
"weak reference will always be nil because the referenced object is "
"deallocated here", ())

// performance diagnostics
ERROR(performance_annotations_not_enabled,none,
"use -experimental-performance-annotations to enable performance annotations", ())
ERROR(performance_dynamic_casting,none,
"dynamic casting can lock or allocate", ())
ERROR(performance_metadata,none,
"%0 can cause metadata allocation or locks", (StringRef))
ERROR(performance_metadata_type,none,
"Using type %0 can cause metadata allocation or locks", (Type))
ERROR(performance_allocating,none,
"%0 can cause an allocation", (StringRef))
ERROR(performance_deallocating,none,
"%0 can cause an deallocation", (StringRef))
ERROR(performance_deallocating_type,none,
"%0 a value of type %1 can cause a deallocation", (StringRef, Type))
ERROR(performance_locking,none,
"%0 can cause locking", (StringRef))
ERROR(performance_arc,none,
"this code performs reference counting operations which can cause locking", ())
ERROR(performance_objectivec,none,
"calls of Objective-C methods can have unpredictable performance", ())
ERROR(performance_unknown_callees,none,
"called function is not known at compile time and can have unpredictable performance", ())
ERROR(performance_callee_unavailable,none,
"called function is not availbale in this module and can have unpredictable performance", ())
NOTE(performance_called_from,none,
"called from here", ())

// 'transparent' diagnostics
ERROR(circular_transparent,none,
"inlining 'transparent' functions forms circular loop", ())
Expand Down
5 changes: 4 additions & 1 deletion include/swift/AST/SILOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ class SILOptions {

/// Controls whether cross module optimization is enabled.
bool CrossModuleOptimization = false;


/// Enables experimental performance annotations.
bool EnablePerformanceAnnotations = false;

/// Controls whether or not paranoid verification checks are run.
bool VerifyAll = false;

Expand Down
2 changes: 2 additions & 0 deletions include/swift/AST/SemanticAttrs.def
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,7 @@ SEMANTICS_ATTR(OBJC_FORBID_ASSOCIATED_OBJECTS, "objc.forbidAssociatedObjects")

SEMANTICS_ATTR(LIFETIMEMANAGEMENT_MOVE, "lifetimemanagement.move")

SEMANTICS_ATTR(NO_PERFORMANCE_ANALYSIS, "no_performance_analysis")

#undef SEMANTICS_ATTR

9 changes: 9 additions & 0 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,10 @@ def CrossModuleOptimization : Flag<["-"], "cross-module-optimization">,
Flags<[HelpHidden, FrontendOption]>,
HelpText<"Perform cross-module optimization">;

def ExperimentalPerformanceAnnotations : Flag<["-"], "experimental-performance-annotations">,
Flags<[HelpHidden, FrontendOption]>,
HelpText<"Perform cross-module optimization">;

def RemoveRuntimeAsserts : Flag<["-"], "remove-runtime-asserts">,
Flags<[FrontendOption]>,
HelpText<"Remove runtime safety checks.">;
Expand Down Expand Up @@ -1278,6 +1282,11 @@ def emit_symbol_graph_dir : Separate<["-"], "emit-symbol-graph-dir">,
HelpText<"Emit a symbol graph to directory <dir>">,
MetaVarName<"<dir>">;

def symbol_graph_minimum_access_level: Separate<["-"], "symbol-graph-minimum-access-level">,
Flags<[FrontendOption, NoInteractiveOption, SupplementaryOutput, HelpHidden]>,
HelpText<"Include symbols with this access level or more when emitting a symbol graph">,
MetaVarName<"<level>">;

def pretty_print: Flag<["-"], "pretty-print">,
Flags<[SwiftAPIExtractOption, SwiftSymbolGraphExtractOption]>,
HelpText<"Pretty-print the output JSON">;
Expand Down
1 change: 0 additions & 1 deletion include/swift/Reflection/ReflectionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,6 @@ class ReflectionContext
MetadataAllocation<Runtime> Allocation) {
if (Allocation.Tag == GenericMetadataCacheTag) {
struct GenericMetadataCacheEntry {
StoredPointer Left, Right;
StoredPointer LockedStorage;
uint8_t LockedStorageKind;
uint8_t TrackingInfo;
Expand Down
1 change: 1 addition & 0 deletions include/swift/Runtime/RuntimeFnWrappersGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#ifndef SWIFT_RUNTIME_RUNTIMEFNWRAPPERSGEN_H
#define SWIFT_RUNTIME_RUNTIMEFNWRAPPERSGEN_H

#include "swift/SIL/RuntimeEffect.h"
#include "llvm/IR/Module.h"
#include "llvm/ADT/ArrayRef.h"

Expand Down
Loading