Skip to content

[pull] swiftwasm from main #5529

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 51 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2f07371
build: update build rules for new MSI set
compnerd Jun 9, 2023
8f0c2d3
[Driver] Remove unused runtime library path on non-Darwin platforms
finagolfin Jun 11, 2023
bf5612c
[AST] ASTDumper: Print overload choices of non-operator `OverloadedDe…
xedin Jun 14, 2023
bf5ecf0
Add reference documentation to Observation symbols.
kirbyt Jun 14, 2023
654f21f
Enable opaque pointers
aschwaighofer May 4, 2023
5d1378d
Add a `%use_no_opaque_pointers` subsitution for tests
aschwaighofer May 11, 2023
c1a93e0
Move tests over to use the `%use_no_opaque_pointers` option
aschwaighofer May 11, 2023
316e982
Fix linux tests
aschwaighofer May 23, 2023
8f7e433
Fix LTO test to use just use libLTO.dylib
aschwaighofer May 23, 2023
307a6d8
Fix test/IRGen/objc_properties_ios.swift
aschwaighofer May 24, 2023
e6d070d
Try to only remove comdata if the global is a declaration
aschwaighofer May 24, 2023
d1d7438
Move windows tests to `%use_no_opaque_pointers` usage
aschwaighofer May 25, 2023
90c7193
More IRGen test to move over
aschwaighofer Jun 8, 2023
0d4dec1
Attempt to fix debug info under opaque pointers
aschwaighofer Jun 13, 2023
37e6741
Apply review feedback.
kirbyt Jun 14, 2023
410b770
Apply suggested coding style.
kirbyt Jun 14, 2023
837f6e0
Fix typo.
kirbyt Jun 14, 2023
367a7f6
Replace fenced code blocks with indentions.
kirbyt Jun 14, 2023
5791a2c
[Macros] Plugin search options group
rintaro Jun 14, 2023
eb858d9
[ConstraintSystem] Use an explicit generic argument constraint for
hborla Jun 15, 2023
f9d7c73
Add a test case for returning a closure that captures a pack
rjmccall Jun 14, 2023
3332ce7
[NFC] Add a utility for this load take/borrow dance
rjmccall Jun 14, 2023
43f4b9f
Load pack elements in memberwise initializers if they're loadable
rjmccall Jun 14, 2023
acbd4a6
Fix the emission of closures into reabstracted contexts with
rjmccall Jun 15, 2023
d357315
[ConstraintSystem] Handle typealiases in ExplicitGenericArguments
hborla Jun 15, 2023
3f401fb
[test] Require asserts for a couple of tests
hamishknight Jun 15, 2023
d5c3018
Merge pull request #66546 from finagolfin/runtime
egorzhdan Jun 15, 2023
9abe0b9
Merge pull request #66636 from kirbyt/kirbyt/observation-docs-109798110
kirbyt Jun 15, 2023
5998816
Merge pull request #66667 from hamishknight/asserts
swift-ci Jun 15, 2023
e69c301
Merge pull request #66658 from rjmccall/variadic-generics-fixes
rjmccall Jun 15, 2023
85d59d2
don't use Clang modules in the "only re-export public symbols" check …
QuietMisdreavus Jun 15, 2023
612a2e7
Merge pull request #66657 from hborla/variadic-macro-specialization
hborla Jun 15, 2023
19ad0c5
Merge pull request #66616 from xedin/print-overloaded-ref-expr-choice…
xedin Jun 15, 2023
fe6ccd7
[cxx-interop] Add fix for corner case where NS_OPTIONS typedef has to…
plotfi Jun 14, 2023
a971a0c
AST: Add convenience for limiting diags to warnings in swiftinterfaces.
tshortli Jun 15, 2023
5d5dbd9
Merge pull request #66077 from aschwaighofer/wip_enable_opaque_pointers
aschwaighofer Jun 15, 2023
fccecbe
MandatoryPerformanceOptimizations: remove dead metatype instructions …
eeckstein Jun 13, 2023
fe87b99
PerformanceDiagnostics: when checking closure values, look through `c…
eeckstein Jun 13, 2023
7839b54
GenericSpecializer: drop metatype arguments in specialized functions
eeckstein Jun 15, 2023
4e2213d
Add nullptr checks before accessing children in getUnspecialized
augusto2112 Jun 15, 2023
ee0d1c0
Merge pull request #66514 from compnerd/installer
compnerd Jun 15, 2023
229ad8b
Replace hardcoded special names with call into getUserfacingName()
adrian-prantl Jun 15, 2023
9b7123b
Handle pack expansion types when verifying lowered types in SIL
rjmccall Jun 15, 2023
457c55b
Merge pull request #66650 from rintaro/macros-plugins-searchopts
rintaro Jun 15, 2023
c8f4dab
Sema: Diagnose `@backDeployed` on functions with opaque result types.
tshortli Jun 15, 2023
cc09ecf
Merge pull request #66644 from augusto2112/null-ptr-children-main
augusto2112 Jun 15, 2023
b140bc3
Merge pull request #66619 from plotfi/plotfi-cxx-interop-uicontrolsta…
plotfi Jun 15, 2023
14f7161
Merge pull request #66682 from adrian-prantl/109173022
swift-ci Jun 16, 2023
5dc59a5
Merge pull request #66683 from rjmccall/lowered-pack-expansion-verifi…
rjmccall Jun 16, 2023
de31b13
Merge pull request #66662 from eeckstein/fix-specializer
eeckstein Jun 16, 2023
79616c4
Merge pull request #66673 from tshortli/diagnose-back-deployed-opaque…
tshortli Jun 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,15 @@ private func optimize(function: Function, _ context: FunctionPassContext) {
switch instruction {
case let apply as FullApplySite:
inlineAndDevirtualize(apply: apply, context, simplifyCtxt)
case let mt as MetatypeInst:
if mt.isTriviallyDeadIgnoringDebugUses {
simplifyCtxt.erase(instructionIncludingDebugUses: mt)
}
default:
break
}
}

_ = context.specializeApplies(in: function, isMandatory: true)

removeUnusedMetatypeInstructions(in: function, context)

// If this is a just specialized function, try to optimize copy_addr, etc.
if context.optimizeMemoryAccesses(in: function) {
_ = context.eliminateDeadAllocations(in: function)
Expand Down Expand Up @@ -103,6 +101,15 @@ private func inlineAndDevirtualize(apply: FullApplySite, _ context: FunctionPass
}
}

private func removeUnusedMetatypeInstructions(in function: Function, _ context: FunctionPassContext) {
for inst in function.instructions {
if let mt = inst as? MetatypeInst,
mt.isTriviallyDeadIgnoringDebugUses {
context.erase(instructionIncludingDebugUses: mt)
}
}
}

private func shouldInline(apply: FullApplySite, callee: Function) -> Bool {
if callee.isTransparent {
return true
Expand Down
9 changes: 9 additions & 0 deletions include/swift/AST/DiagnosticEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,15 @@ namespace swift {
/// until the next major language version.
InFlightDiagnostic &warnUntilSwiftVersion(unsigned majorVersion);

/// Limit the diagnostic behavior to warning if the context is a
/// swiftinterface.
///
/// This is useful for diagnostics for restrictions that may be lifted by a
/// future version of the compiler. In such cases, it may be helpful to
/// avoid failing to build a module from its interface if the interface was
/// emitted using a compiler that no longer has the restriction.
InFlightDiagnostic &warnInSwiftInterface(const DeclContext *context);

/// Conditionally limit the diagnostic behavior to warning until
/// the specified version. If the condition is false, no limit is
/// imposed, meaning (presumably) it is treated as an error.
Expand Down
4 changes: 4 additions & 0 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -7053,6 +7053,10 @@ ERROR(attr_incompatible_with_back_deploy,none,
"'%0' cannot be applied to a back deployed %1",
(DeclAttribute, DescriptiveDeclKind))

ERROR(backdeployed_opaque_result_not_supported,none,
"'%0' is unsupported on a %1 with a 'some' return type",
(DeclAttribute, DescriptiveDeclKind))

//------------------------------------------------------------------------------
// MARK: Implicit opening of existential types
//------------------------------------------------------------------------------
Expand Down
37 changes: 13 additions & 24 deletions include/swift/AST/PluginLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,19 @@ class PluginLoader {
void setRegistry(PluginRegistry *newValue);
PluginRegistry *getRegistry();

/// Lookup a library plugin that can handle \p moduleName and return the path
/// to it from `-load-plugin-library`.
/// The path returned can be loaded by 'loadLibraryPlugin' method.
llvm::Optional<std::string>
lookupExplicitLibraryPluginByModuleName(Identifier moduleName);

/// Lookup a library plugin that can handle \p moduleName and return the path
/// to it from `-plugin-path`.
/// The path returned can be loaded by 'loadLibraryPlugin' method.
llvm::Optional<std::string>
lookupLibraryPluginInSearchPathByModuleName(Identifier moduleName);

/// Lookup an executable plugin that is declared to handle \p moduleName
/// module by '-load-plugin-executable'.
/// The path returned can be loaded by 'loadExecutablePlugin' method.
llvm::Optional<StringRef>
lookupExecutablePluginByModuleName(Identifier moduleName);

/// Look for dynamic libraries in paths from `-external-plugin-path` and
/// return a pair of `(library path, plugin server executable)` if found.
/// These paths are valid within the VFS, use `FS.getRealPath()` for their
/// underlying path.
llvm::Optional<std::pair<std::string, std::string>>
lookupExternalLibraryPluginByModuleName(Identifier moduleName);
/// Lookup a plugin that can handle \p moduleName and return the path(s) to
/// it. The path returned can be loaded by 'load(Library|Executable)Plugin()'.
/// The return value is a pair of a "library path" and a "executable path".
///
/// * (libPath: empty, execPath: empty) - plugin not found.
/// * (libPath: some, execPath: empty) - load the library path by
/// 'loadLibraryPlugin()'.
/// * (libPath: empty, execPath: some) - load the executable path by
/// 'loadExecutablePlugin()'.
/// * (libPath: some, execPath: some) - load the executable path by
/// 'loadExecutablePlugin()' and let the plugin load the libPath via IPC.
std::pair<std::string, std::string>
lookupPluginByModuleName(Identifier moduleName);

/// Load the specified dylib plugin path resolving the path with the
/// current VFS. If it fails to load the plugin, a diagnostic is emitted, and
Expand Down
62 changes: 23 additions & 39 deletions include/swift/AST/SearchPathOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "swift/Basic/ArrayRefView.h"
#include "swift/Basic/PathRemapper.h"
#include "swift/Basic/TaggedUnion.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/StringMap.h"
Expand All @@ -34,7 +35,6 @@ enum class ModuleSearchPathKind {
Framework,
DarwinImplicitFramework,
RuntimeLibrary,
CompilerPlugin,
};

/// A single module search path that can come from different sources, e.g.
Expand Down Expand Up @@ -187,6 +187,26 @@ struct ExternalPluginSearchPathAndServerPath {
std::string ServerPath;
};

namespace PluginSearchOption {
struct LoadPluginLibrary {
std::string LibraryPath;
};
struct LoadPluginExecutable {
std::string ExecutablePath;
std::vector<std::string> ModuleNames;
};
struct PluginPath {
std::string SearchPath;
};
struct ExternalPluginPath {
std::string SearchPath;
std::string ServerPath;
};

using Value = TaggedUnion<LoadPluginLibrary, LoadPluginExecutable, PluginPath,
ExternalPluginPath>;
} // namespace PluginSearchOption

/// Options for controlling search path behavior.
class SearchPathOptions {
/// To call \c addImportSearchPath and \c addFrameworkSearchPath from
Expand Down Expand Up @@ -259,14 +279,6 @@ class SearchPathOptions {
ImportSearchPaths.size() - 1);
}

void addCompilerPluginLibraryPath(StringRef Path, llvm::vfs::FileSystem *FS) {
CompilerPluginLibraryPaths.push_back(Path.str());
Lookup.searchPathAdded(FS, CompilerPluginLibraryPaths.back(),
ModuleSearchPathKind::CompilerPlugin,
/*isSystem=*/false,
CompilerPluginLibraryPaths.size() - 1);
}

/// Add a single framework search path. Must only be called from
/// \c ASTContext::addSearchPath.
void addFrameworkSearchPath(FrameworkSearchPath NewPath,
Expand Down Expand Up @@ -355,27 +367,6 @@ class SearchPathOptions {
Lookup.searchPathsDidChange();
}

void setCompilerPluginLibraryPaths(
std::vector<std::string> NewCompilerPluginLibraryPaths) {
CompilerPluginLibraryPaths = NewCompilerPluginLibraryPaths;
Lookup.searchPathsDidChange();
}

ArrayRef<std::string> getCompilerPluginLibraryPaths() const {
return CompilerPluginLibraryPaths;
}

void setCompilerPluginExecutablePaths(
std::vector<PluginExecutablePathAndModuleNames> &&newValue) {
CompilerPluginExecutablePaths = std::move(newValue);
Lookup.searchPathsDidChange();
}

ArrayRef<PluginExecutablePathAndModuleNames>
getCompilerPluginExecutablePaths() const {
return CompilerPluginExecutablePaths;
}

/// Path(s) to virtual filesystem overlay YAML files.
std::vector<std::string> VFSOverlayFiles;

Expand All @@ -391,15 +382,8 @@ class SearchPathOptions {
/// preference.
std::vector<std::string> RuntimeLibraryPaths;

/// Paths that contain compiler plugins loaded on demand for, e.g.,
/// macro implementations.
std::vector<std::string> PluginSearchPaths;

/// Pairs of external compiler plugin search paths and the corresponding
/// plugin server executables.
/// e.g. {"/path/to/usr/lib/swift/host/plugins",
/// "/path/to/usr/bin/plugin-server"}
std::vector<ExternalPluginSearchPathAndServerPath> ExternalPluginSearchPaths;
/// Plugin search path options.
std::vector<PluginSearchOption::Value> PluginSearchOpts;

/// Don't look in for compiler-provided modules.
bool SkipRuntimeLibraryImportPaths = false;
Expand Down
8 changes: 0 additions & 8 deletions include/swift/Frontend/Frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,6 @@ class CompilerInvocation {
SearchPathOpts.VFSOverlayFiles = Overlays;
}

void setCompilerPluginLibraryPaths(const std::vector<std::string> &Paths) {
SearchPathOpts.setCompilerPluginLibraryPaths(Paths);
}

ArrayRef<std::string> getCompilerPluginLibraryPaths() {
return SearchPathOpts.getCompilerPluginLibraryPaths();
}

void setExtraClangArgs(const std::vector<std::string> &Args) {
ClangImporterOpts.ExtraArgs = Args;
}
Expand Down
25 changes: 14 additions & 11 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,6 @@ def I : JoinedOrSeparate<["-"], "I">,
def I_EQ : Joined<["-"], "I=">, Flags<[FrontendOption, ArgumentIsPath]>,
Alias<I>;

def plugin_path : Separate<["-"], "plugin-path">,
Flags<[FrontendOption, ArgumentIsPath, SwiftAPIExtractOption, SwiftSymbolGraphExtractOption, SwiftAPIDigesterOption]>,
HelpText<"Add directory to the plugin search path">;

def external_plugin_path : Separate<["-"], "external-plugin-path">,
Flags<[FrontendOption, ArgumentIsPath, SwiftAPIExtractOption, SwiftSymbolGraphExtractOption, SwiftAPIDigesterOption]>,
HelpText<"Add directory to the plugin search path with a plugin server executable">,
MetaVarName<"<path>#<plugin-server-path>">;

def import_underlying_module : Flag<["-"], "import-underlying-module">,
Flags<[FrontendOption, NoInteractiveOption]>,
HelpText<"Implicitly imports the Objective-C half of a module">;
Expand Down Expand Up @@ -1852,15 +1843,27 @@ def clang_include_tree_root: Separate<["-"], "clang-include-tree-root">,
Flags<[FrontendOption, NoDriverOption]>,
HelpText<"Clang Include Tree CASID">, MetaVarName<"<cas-id>">;


def plugin_search_Group : OptionGroup<"<plugin search options>">;

def plugin_path : Separate<["-"], "plugin-path">, Group<plugin_search_Group>,
Flags<[FrontendOption, ArgumentIsPath, SwiftAPIExtractOption, SwiftSymbolGraphExtractOption, SwiftAPIDigesterOption]>,
HelpText<"Add directory to the plugin search path">;

def external_plugin_path : Separate<["-"], "external-plugin-path">, Group<plugin_search_Group>,
Flags<[FrontendOption, ArgumentIsPath, SwiftAPIExtractOption, SwiftSymbolGraphExtractOption, SwiftAPIDigesterOption]>,
HelpText<"Add directory to the plugin search path with a plugin server executable">,
MetaVarName<"<path>#<plugin-server-path>">;

def load_plugin_library:
Separate<["-"], "load-plugin-library">,
Separate<["-"], "load-plugin-library">, Group<plugin_search_Group>,
Flags<[FrontendOption, DoesNotAffectIncrementalBuild, ArgumentIsPath]>,
HelpText<"Path to a dynamic library containing compiler plugins such as "
"macros">,
MetaVarName<"<path>">;

def load_plugin_executable:
Separate<["-"], "load-plugin-executable">,
Separate<["-"], "load-plugin-executable">, Group<plugin_search_Group>,
Flags<[FrontendOption, DoesNotAffectIncrementalBuild, ArgumentIsPath]>,
HelpText<"Path to an executable compiler plugins and providing module names "
"such as macros">,
Expand Down
16 changes: 16 additions & 0 deletions include/swift/SIL/AbstractionPatternGenerators.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,22 @@ class TupleElementGenerator {
}
}

/// Like `getSubstTypes`, but uses a different and possibly
/// non-canonical tuple type.
TupleEltTypeArrayRef getSubstTypes(Type ncSubstType) const {
assert(!isFinished());
if (!origTupleVanishes) {
return ncSubstType->castTo<TupleType>()
->getElementTypes().slice(substEltIndex,
numSubstEltsForOrigElt);
} else if (numSubstEltsForOrigElt == 0) {
return TupleEltTypeArrayRef();
} else {
scratchSubstElt = TupleTypeElt(ncSubstType);
return TupleEltTypeArrayRef(scratchSubstElt);
}
}

/// Call this to finalize the traversal and assert that it was done
/// properly.
void finish() {
Expand Down
3 changes: 2 additions & 1 deletion include/swift/SIL/GenericSpecializationMangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ class GenericSpecializationMangler : public SpecializationMangler {
: SpecializationMangler(SpecializationPass::GenericSpecializer,
Serialized, F) {}

std::string mangleNotReabstracted(SubstitutionMap subs);
std::string mangleNotReabstracted(SubstitutionMap subs,
bool metatyeParamsRemoved);

/// Mangle a generic specialization with re-abstracted parameters.
///
Expand Down
16 changes: 9 additions & 7 deletions include/swift/SILOptimizer/Utils/Generics.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ class ReabstractionInfo {
LoadableAndTrivial
};

unsigned param2ArgIndex(unsigned ParamIdx) const {
return ParamIdx + NumFormalIndirectResults;
}

// Create a new substituted type with the updated signature.
CanSILFunctionType createSubstitutedType(SILFunction *OrigF,
SubstitutionMap SubstMap,
Expand Down Expand Up @@ -199,8 +195,8 @@ class ReabstractionInfo {
ApplySite Apply, SILFunction *Callee,
SubstitutionMap ParamSubs,
IsSerialized_t Serialized,
bool ConvertIndirectToDirect = true,
bool dropMetatypeArgs = false,
bool ConvertIndirectToDirect,
bool dropMetatypeArgs,
OptRemark::Emitter *ORE = nullptr);

/// Constructs the ReabstractionInfo for generic function \p Callee with
Expand All @@ -214,7 +210,11 @@ class ReabstractionInfo {
IsSerialized_t isSerialized() const {
return Serialized;
}


unsigned param2ArgIndex(unsigned ParamIdx) const {
return ParamIdx + NumFormalIndirectResults;
}

/// Returns true if the specialized function needs an alternative mangling.
/// See hasConvertedResilientParams.
bool needAlternativeMangling() const {
Expand Down Expand Up @@ -314,6 +314,8 @@ class ReabstractionInfo {
CanSILFunctionType createSpecializedType(CanSILFunctionType SubstFTy,
SILModule &M) const;

CanSILFunctionType createThunkType(PartialApplyInst *forPAI) const;

SILFunction *getNonSpecializedFunction() const { return Callee; }

/// Map type into a context of the specialized function.
Expand Down
11 changes: 4 additions & 7 deletions lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ llvm::StringRef swift::getProtocolName(KnownProtocolKind kind) {
}

namespace {
enum class SearchPathKind : uint8_t {
Import = 1 << 0,
Framework = 1 << 1,
CompilerPlugin = 1 << 2
};
enum class SearchPathKind : uint8_t {
Import = 1 << 0,
Framework = 1 << 1,
};
} // end anonymous namespace

using AssociativityCacheType =
Expand Down Expand Up @@ -694,8 +693,6 @@ ASTContext::ASTContext(
getImpl().SearchPathsSet[path] |= SearchPathKind::Import;
for (const auto &framepath : SearchPathOpts.getFrameworkSearchPaths())
getImpl().SearchPathsSet[framepath.Path] |= SearchPathKind::Framework;
for (StringRef path : SearchPathOpts.getCompilerPluginLibraryPaths())
getImpl().SearchPathsSet[path] |= SearchPathKind::CompilerPlugin;

// Register any request-evaluator functions available at the AST layer.
registerAccessRequestFunctions(evaluator);
Expand Down
11 changes: 11 additions & 0 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2128,6 +2128,17 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
PrintWithColorRAII(OS, ExprModifierColor)
<< " number_of_decls=" << E->getDecls().size()
<< " function_ref=" << getFunctionRefKindStr(E->getFunctionRefKind());
if (!E->isForOperator()) {
PrintWithColorRAII(OS, ExprModifierColor) << " decls=[\n";
interleave(
E->getDecls(),
[&](ValueDecl *D) {
OS.indent(Indent + 2);
D->dumpRef(PrintWithColorRAII(OS, DeclModifierColor).getOS());
},
[&] { PrintWithColorRAII(OS, DeclModifierColor) << ",\n"; });
PrintWithColorRAII(OS, ExprModifierColor) << "]";
}
PrintWithColorRAII(OS, ParenthesisColor) << ')';
}
void visitUnresolvedDeclRefExpr(UnresolvedDeclRefExpr *E) {
Expand Down
Loading