Skip to content

[pull] swiftwasm from main #4364

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 24 commits into from
Mar 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b0a326c
Add a nullptr check
adrian-prantl Mar 11, 2022
e717330
RequirementMachine: Minor optimization
slavapestov Mar 10, 2022
54c83ea
RequirementMachine: Make some low-cost assertions unconditional
slavapestov Mar 10, 2022
f59ffbb
RequirementMachine: Remove unused field from RewriteContext
slavapestov Mar 10, 2022
f082c02
RequirementMachine: Plumb through the loop candidate to isRedundantRu…
slavapestov Feb 28, 2022
3641b77
RequirementMachine: Split up first pass of homotopy reduction into two
slavapestov Mar 10, 2022
5cfee4e
RequirementMachine: Stricter invariants in verifyRewriteRules()
slavapestov Mar 10, 2022
a259844
RequirementMachine: Record those rewrite loops involving protocol typ…
slavapestov Mar 10, 2022
1f83cd0
RequirementMachine: Don't eliminate a rule via a path involving a pro…
slavapestov Mar 10, 2022
3cb7af0
Move SILGenFunction::buildThunkType out to a utility function
DougGregor Mar 11, 2022
9c13426
Collapse the differentiation-specific thunk type generation code into…
DougGregor Mar 12, 2022
746080d
[ClangImporter] Suffix ambiguous protocol names if C++ interop is ena…
drodriguez Feb 16, 2022
8298c72
Merge pull request #41790 from adrian-prantl/89177494
swift-ci Mar 12, 2022
42f8ef5
Revert "[test] Disable a couple of DebugInfo tests"
gottesmm Mar 9, 2022
4d5d9e3
Merge pull request #41792 from DougGregor/collapse-thunk-types
DougGregor Mar 12, 2022
cb56373
Merge pull request #41410 from drodriguez/class-protocol-name-clash
swift-ci Mar 12, 2022
9bf7a6e
[cxx-interop][test] cleanup the lit.local.cfg for reverse Interop tests
hyp Mar 12, 2022
2c2fa56
[cxx-interop][test] add %check-interop-cxx-header-in-clang test comma…
hyp Mar 12, 2022
cfe0b97
[Reflection] Update MemoryReader to distinguish related operations (#…
kastiglione Mar 12, 2022
0d65e88
Merge pull request #41794 from hyp/cxx-multilang-substitute
hyp Mar 12, 2022
000a41d
sema: reject enum element call with payloads as compile-time constant
nkcsgexi Mar 12, 2022
d397821
Merge pull request #41793 from gottesmm/pr-f5659d1145565a5c7ea88bc8ee…
gottesmm Mar 12, 2022
b6047e2
Merge pull request #41796 from nkcsgexi/90168664
nkcsgexi Mar 12, 2022
965f32d
Merge pull request #41773 from slavapestov/rqm-concrete-protocol-type…
slavapestov Mar 13, 2022
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
23 changes: 18 additions & 5 deletions include/swift/Remote/MemoryReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,32 @@ class MemoryReader {
return RemoteAbsolutePointer("", readValue);
}

/// Atempt to resolve the pointer to a symbol for the given remote address.
virtual llvm::Optional<RemoteAbsolutePointer>
resolvePointerAsSymbol(RemoteAddress address) {
return llvm::None;
}

/// Lookup a symbol for the given remote address.
virtual RemoteAbsolutePointer getSymbol(RemoteAddress address) {
if (auto symbol = resolvePointerAsSymbol(address))
return *symbol;
return RemoteAbsolutePointer("", address.getAddressData());
}

/// Lookup a dynamic symbol name (ie dynamic loader binding) for the given
/// remote address. Note: An address can be referenced by both dynamic and
/// regular symbols, this function must return a dynamic symbol only.
virtual RemoteAbsolutePointer getDynamicSymbol(RemoteAddress address) {
return nullptr;
}

/// Attempt to read and resolve a pointer value at the given remote address.
llvm::Optional<RemoteAbsolutePointer> readPointer(RemoteAddress address,
unsigned pointerSize) {
// Try to resolve the pointer as a symbol first, as reading memory
// may potentially be expensive.
if (auto symbolPointer = resolvePointerAsSymbol(address))
return symbolPointer;
// First, try to lookup the pointer as a dynamic symbol (binding), as
// reading memory may potentially be expensive.
if (auto dynamicSymbol = getDynamicSymbol(address))
return dynamicSymbol;

auto result = readBytes(address, pointerSize);
if (!result)
Expand Down
6 changes: 1 addition & 5 deletions include/swift/Remote/MetadataReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,7 @@ class MetadataReader {
return nullptr;
}
} else {
resolved = Reader->resolvePointer(RemoteAddress(remoteAddress), 0);
if (resolved.getSymbol().empty()) {
// No symbol found, use the already calculated address.
resolved = RemoteAbsolutePointer("", remoteAddress);
}
resolved = Reader->getSymbol(RemoteAddress(remoteAddress));
}

switch (kind) {
Expand Down
33 changes: 33 additions & 0 deletions include/swift/SIL/TypeLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,39 @@ CanSILFunctionType getNativeSILFunctionType(
Optional<SubstitutionMap> reqtSubs = None,
ProtocolConformanceRef witnessMethodConformance = ProtocolConformanceRef());

/// The thunk kinds used in the differentiation transform.
enum class DifferentiationThunkKind {
/// A reabstraction thunk.
///
/// Reabstraction thunks transform a function-typed value to another one with
/// different parameter/result abstraction patterns. This is identical to the
/// thunks generated by SILGen.
Reabstraction,

/// An index subset thunk.
///
/// An index subset thunk is used transform JVP/VJPs into a version that is
/// "wrt" fewer differentiation parameters.
/// - Differentials of thunked JVPs use zero for non-requested differentiation
/// parameters.
/// - Pullbacks of thunked VJPs discard results for non-requested
/// differentiation parameters.
IndexSubset
};

/// Build the type of a function transformation thunk.
CanSILFunctionType buildSILFunctionThunkType(
SILFunction *fn,
CanSILFunctionType &sourceType,
CanSILFunctionType &expectedType,
CanType &inputSubstType,
CanType &outputSubstType,
GenericEnvironment *&genericEnv,
SubstitutionMap &interfaceSubs,
CanType &dynamicSelfType,
bool withoutActuallyEscaping,
Optional<DifferentiationThunkKind> differentiationThunkKind = None);

} // namespace swift

namespace llvm {
Expand Down
35 changes: 0 additions & 35 deletions include/swift/SILOptimizer/Differentiation/Thunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,41 +47,6 @@ class ADContext;
// moved to a shared location.
//===----------------------------------------------------------------------===//

/// The thunk kinds used in the differentiation transform.
enum class DifferentiationThunkKind {
/// A reabstraction thunk.
///
/// Reabstraction thunks transform a function-typed value to another one with
/// different parameter/result abstraction patterns. This is identical to the
/// thunks generated by SILGen.
Reabstraction,

/// An index subset thunk.
///
/// An index subset thunk is used transform JVP/VJPs into a version that is
/// "wrt" fewer differentiation parameters.
/// - Differentials of thunked JVPs use zero for non-requested differentiation
/// parameters.
/// - Pullbacks of thunked VJPs discard results for non-requested
/// differentiation parameters.
IndexSubset
};

CanGenericSignature buildThunkSignature(SILFunction *fn, bool inheritGenericSig,
OpenedArchetypeType *openedExistential,
GenericEnvironment *&genericEnv,
SubstitutionMap &contextSubs,
SubstitutionMap &interfaceSubs,
ArchetypeType *&newArchetype);

/// Build the type of a function transformation thunk.
CanSILFunctionType buildThunkType(SILFunction *fn,
CanSILFunctionType &sourceType,
CanSILFunctionType &expectedType,
GenericEnvironment *&genericEnv,
SubstitutionMap &interfaceSubs,
bool withoutActuallyEscaping,
DifferentiationThunkKind thunkKind);

/// Get or create a reabstraction thunk from `fromType` to `toType`, to be
/// called in `caller`.
Expand Down
5 changes: 5 additions & 0 deletions include/swift/StaticMirror/ObjectFileContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class Image {

remote::RemoteAbsolutePointer resolvePointer(uint64_t Addr,
uint64_t pointerValue) const;

remote::RemoteAbsolutePointer getDynamicSymbol(uint64_t Addr) const;
};

/// MemoryReader that reads from the on-disk representation of an executable
Expand Down Expand Up @@ -118,6 +120,9 @@ class ObjectMemoryReader : public reflection::MemoryReader {

remote::RemoteAbsolutePointer resolvePointer(reflection::RemoteAddress Addr,
uint64_t pointerValue) override;

remote::RemoteAbsolutePointer
getDynamicSymbol(reflection::RemoteAddress Addr) override;
};

using ReflectionContextOwner = std::unique_ptr<void, void (*)(void *)>;
Expand Down
9 changes: 8 additions & 1 deletion lib/AST/RequirementMachine/GenericSignatureQueries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ RequirementMachine::getLongestValidPrefix(const MutableTerm &term) const {
case Symbol::Kind::Superclass:
case Symbol::Kind::ConcreteType:
case Symbol::Kind::ConcreteConformance:
llvm_unreachable("Property symbol cannot appear in a type term");
llvm::errs() <<"Invalid symbol in a type term: " << term << "\n";
abort();
}

// This symbol is valid, add it to the longest prefix.
Expand All @@ -265,6 +266,9 @@ bool RequirementMachine::isCanonicalTypeInContext(Type type) const {
explicit Walker(const RequirementMachine &self) : Self(self) {}

Action walkToTypePre(Type component) override {
if (!component->hasTypeParameter())
return Action::SkipChildren;

if (!component->isTypeParameter())
return Action::Continue;

Expand Down Expand Up @@ -305,6 +309,9 @@ Type RequirementMachine::getCanonicalTypeInContext(
TypeArrayView<GenericTypeParamType> genericParams) const {

return type.transformRec([&](Type t) -> Optional<Type> {
if (!t->hasTypeParameter())
return t;

if (!t->isTypeParameter())
return None;

Expand Down
Loading