Merge remote-tracking branch 'origin/main' into next

This commit is contained in:
swift_jenkins
2020-10-07 14:46:15 -07:00
28 changed files with 441 additions and 144 deletions

View File

@@ -127,7 +127,7 @@ public:
} }
}; };
class CompileJobAction : public JobAction { class IncrementalJobAction : public JobAction {
public: public:
struct InputInfo { struct InputInfo {
enum Status { enum Status {
@@ -136,6 +136,8 @@ public:
NeedsNonCascadingBuild, NeedsNonCascadingBuild,
NewlyAdded NewlyAdded
}; };
public:
Status status = UpToDate; Status status = UpToDate;
llvm::sys::TimePoint<> previousModTime; llvm::sys::TimePoint<> previousModTime;
@@ -153,18 +155,32 @@ private:
InputInfo inputInfo; InputInfo inputInfo;
public: public:
CompileJobAction(file_types::ID OutputType) IncrementalJobAction(Kind Kind, ArrayRef<const Action *> Inputs,
: JobAction(Action::Kind::CompileJob, None, OutputType), file_types::ID Type, InputInfo info)
inputInfo() {} : JobAction(Kind, Inputs, Type), inputInfo(info) {}
CompileJobAction(Action *Input, file_types::ID OutputType, InputInfo info)
: JobAction(Action::Kind::CompileJob, Input, OutputType),
inputInfo(info) {}
public:
InputInfo getInputInfo() const { InputInfo getInputInfo() const {
return inputInfo; return inputInfo;
} }
public:
static bool classof(const Action *A) {
return A->getKind() == Action::Kind::CompileJob;
}
};
class CompileJobAction : public IncrementalJobAction {
private:
virtual void anchor() override;
public:
CompileJobAction(file_types::ID OutputType)
: IncrementalJobAction(Action::Kind::CompileJob, None, OutputType, {}) {}
CompileJobAction(Action *Input, file_types::ID OutputType, InputInfo info)
: IncrementalJobAction(Action::Kind::CompileJob, Input, OutputType,
info) {}
static bool classof(const Action *A) { static bool classof(const Action *A) {
return A->getKind() == Action::Kind::CompileJob; return A->getKind() == Action::Kind::CompileJob;
} }

View File

@@ -43,6 +43,8 @@ void InputAction::anchor() {}
void JobAction::anchor() {} void JobAction::anchor() {}
void IncrementalJobAction::anchor() {}
void CompileJobAction::anchor() {} void CompileJobAction::anchor() {}
void InterpretJobAction::anchor() {} void InterpretJobAction::anchor() {}

View File

@@ -860,7 +860,7 @@ namespace driver {
computeFirstRoundCompileJobsForIncrementalCompilation(); computeFirstRoundCompileJobsForIncrementalCompilation();
for (const Job *Cmd : Comp.getJobs()) { for (const Job *Cmd : Comp.getJobs()) {
if (Cmd->getFirstSwiftPrimaryInput().empty() || if (!isa<IncrementalJobAction>(Cmd->getSource()) ||
compileJobsToSchedule.count(Cmd)) { compileJobsToSchedule.count(Cmd)) {
scheduleCommandIfNecessaryAndPossible(Cmd); scheduleCommandIfNecessaryAndPossible(Cmd);
noteBuilding(Cmd, /*willBeBuilding*/ true, /*isTentative=*/false, noteBuilding(Cmd, /*willBeBuilding*/ true, /*isTentative=*/false,
@@ -899,20 +899,22 @@ namespace driver {
CommandSet CommandSet
computeDependenciesAndGetNeededCompileJobs(const bool forRanges) { computeDependenciesAndGetNeededCompileJobs(const bool forRanges) {
auto getEveryCompileJob = [&] { auto getEveryCompileJob = [&] {
CommandSet everyCompileJob; CommandSet everyIncrementalJob;
for (const Job *Cmd : Comp.getJobs()) { for (const Job *Cmd : Comp.getJobs()) {
if (!Cmd->getFirstSwiftPrimaryInput().empty()) if (isa<IncrementalJobAction>(Cmd->getSource()))
everyCompileJob.insert(Cmd); everyIncrementalJob.insert(Cmd);
} }
return everyCompileJob; return everyIncrementalJob;
}; };
CommandSet jobsToSchedule; CommandSet jobsToSchedule;
CommandSet initialCascadingCommands; CommandSet initialCascadingCommands;
for (const Job *cmd : Comp.getJobs()) { for (const Job *cmd : Comp.getJobs()) {
const StringRef primary = cmd->getFirstSwiftPrimaryInput(); // Skip jobs that have no associated incremental info.
if (primary.empty()) if (!isa<IncrementalJobAction>(cmd->getSource())) {
continue; // not Compile continue;
}
const Optional<std::pair<bool, bool>> shouldSchedAndIsCascading = const Optional<std::pair<bool, bool>> shouldSchedAndIsCascading =
computeShouldInitiallyScheduleJobAndDependendents(cmd, forRanges); computeShouldInitiallyScheduleJobAndDependendents(cmd, forRanges);
if (!shouldSchedAndIsCascading) if (!shouldSchedAndIsCascading)

View File

@@ -181,6 +181,28 @@ AsyncContextLayout irgen::getAsyncContextLayout(
paramInfos.push_back({ty, parameter.getConvention()}); paramInfos.push_back({ty, parameter.getConvention()});
} }
Optional<AsyncContextLayout::TrailingWitnessInfo> trailingWitnessInfo;
if (originalType->getRepresentation() ==
SILFunctionTypeRepresentation::WitnessMethod) {
assert(getTrailingWitnessSignatureLength(IGF.IGM, originalType) == 2);
// First, the Self metadata.
{
auto ty = SILType();
auto &ti = IGF.IGM.getTypeMetadataPtrTypeInfo();
valTypes.push_back(ty);
typeInfos.push_back(&ti);
}
// Then, the Self witness table.
{
auto ty = SILType();
auto &ti = IGF.IGM.getWitnessTablePtrTypeInfo();
valTypes.push_back(ty);
typeInfos.push_back(&ti);
}
trailingWitnessInfo = AsyncContextLayout::TrailingWitnessInfo();
}
// ResultTypes directResults...; // ResultTypes directResults...;
auto directResults = fnConv.getDirectSILResults(); auto directResults = fnConv.getDirectSILResults();
for (auto result : directResults) { for (auto result : directResults) {
@@ -192,11 +214,11 @@ AsyncContextLayout irgen::getAsyncContextLayout(
directReturnInfos.push_back(result); directReturnInfos.push_back(result);
} }
return AsyncContextLayout(IGF.IGM, LayoutStrategy::Optimal, valTypes, return AsyncContextLayout(
typeInfos, IGF, originalType, substitutedType, IGF.IGM, LayoutStrategy::Optimal, valTypes, typeInfos, IGF, originalType,
substitutionMap, std::move(bindings), errorType, substitutedType, substitutionMap, std::move(bindings),
canHaveValidError, paramInfos, indirectReturnInfos, trailingWitnessInfo, errorType, canHaveValidError, paramInfos,
directReturnInfos, localContextInfo); indirectReturnInfos, directReturnInfos, localContextInfo);
} }
AsyncContextLayout::AsyncContextLayout( AsyncContextLayout::AsyncContextLayout(
@@ -204,8 +226,8 @@ AsyncContextLayout::AsyncContextLayout(
ArrayRef<const TypeInfo *> fieldTypeInfos, IRGenFunction &IGF, ArrayRef<const TypeInfo *> fieldTypeInfos, IRGenFunction &IGF,
CanSILFunctionType originalType, CanSILFunctionType substitutedType, CanSILFunctionType originalType, CanSILFunctionType substitutedType,
SubstitutionMap substitutionMap, NecessaryBindings &&bindings, SubstitutionMap substitutionMap, NecessaryBindings &&bindings,
SILType errorType, bool canHaveValidError, Optional<TrailingWitnessInfo> trailingWitnessInfo, SILType errorType,
ArrayRef<ArgumentInfo> argumentInfos, bool canHaveValidError, ArrayRef<ArgumentInfo> argumentInfos,
ArrayRef<SILResultInfo> indirectReturnInfos, ArrayRef<SILResultInfo> indirectReturnInfos,
ArrayRef<SILResultInfo> directReturnInfos, ArrayRef<SILResultInfo> directReturnInfos,
Optional<AsyncContextLayout::ArgumentInfo> localContextInfo) Optional<AsyncContextLayout::ArgumentInfo> localContextInfo)
@@ -218,6 +240,7 @@ AsyncContextLayout::AsyncContextLayout(
indirectReturnInfos(indirectReturnInfos.begin(), indirectReturnInfos(indirectReturnInfos.begin(),
indirectReturnInfos.end()), indirectReturnInfos.end()),
localContextInfo(localContextInfo), bindings(std::move(bindings)), localContextInfo(localContextInfo), bindings(std::move(bindings)),
trailingWitnessInfo(trailingWitnessInfo),
argumentInfos(argumentInfos.begin(), argumentInfos.end()) { argumentInfos(argumentInfos.begin(), argumentInfos.end()) {
#ifndef NDEBUG #ifndef NDEBUG
assert(fieldTypeInfos.size() == fieldTypes.size() && assert(fieldTypeInfos.size() == fieldTypes.size() &&
@@ -1931,6 +1954,17 @@ class AsyncCallEmission final : public CallEmission {
getCallee().getSubstitutions()); getCallee().getSubstitutions());
} }
void saveValue(ElementLayout layout, Explosion &explosion, bool isOutlined) {
Address addr = layout.project(IGF, context, /*offsets*/ llvm::None);
auto &ti = cast<LoadableTypeInfo>(layout.getType());
ti.initialize(IGF, explosion, addr, isOutlined);
}
void loadValue(ElementLayout layout, Explosion &explosion) {
Address addr = layout.project(IGF, context, /*offsets*/ llvm::None);
auto &ti = layout.getType();
cast<LoadableTypeInfo>(ti).loadAsTake(IGF, addr, explosion);
}
public: public:
AsyncCallEmission(IRGenFunction &IGF, llvm::Value *selfValue, Callee &&callee) AsyncCallEmission(IRGenFunction &IGF, llvm::Value *selfValue, Callee &&callee)
: CallEmission(IGF, selfValue, std::move(callee)) { : CallEmission(IGF, selfValue, std::move(callee)) {
@@ -1976,21 +2010,15 @@ public:
llArgs.add(selfValue); llArgs.add(selfValue);
} }
auto layout = getAsyncContextLayout(); auto layout = getAsyncContextLayout();
for (unsigned index = 0, count = layout.getArgumentCount(); index < count;
++index) {
auto fieldLayout = layout.getArgumentLayout(index);
Address fieldAddr =
fieldLayout.project(IGF, context, /*offsets*/ llvm::None);
auto &ti = cast<LoadableTypeInfo>(fieldLayout.getType());
ti.initialize(IGF, llArgs, fieldAddr, isOutlined);
}
for (unsigned index = 0, count = layout.getIndirectReturnCount(); for (unsigned index = 0, count = layout.getIndirectReturnCount();
index < count; ++index) { index < count; ++index) {
auto fieldLayout = layout.getIndirectReturnLayout(index); auto fieldLayout = layout.getIndirectReturnLayout(index);
Address fieldAddr = saveValue(fieldLayout, llArgs, isOutlined);
fieldLayout.project(IGF, context, /*offsets*/ llvm::None); }
cast<LoadableTypeInfo>(fieldLayout.getType()) for (unsigned index = 0, count = layout.getArgumentCount(); index < count;
.initialize(IGF, llArgs, fieldAddr, isOutlined); ++index) {
auto fieldLayout = layout.getArgumentLayout(index);
saveValue(fieldLayout, llArgs, isOutlined);
} }
if (layout.hasBindings()) { if (layout.hasBindings()) {
auto bindingLayout = layout.getBindingsLayout(); auto bindingLayout = layout.getBindingsLayout();
@@ -1999,10 +2027,7 @@ public:
} }
if (selfValue) { if (selfValue) {
auto fieldLayout = layout.getLocalContextLayout(); auto fieldLayout = layout.getLocalContextLayout();
Address fieldAddr = saveValue(fieldLayout, llArgs, isOutlined);
fieldLayout.project(IGF, context, /*offsets*/ llvm::None);
auto &ti = cast<LoadableTypeInfo>(fieldLayout.getType());
ti.initialize(IGF, llArgs, fieldAddr, isOutlined);
} }
} }
void emitCallToUnmappedExplosion(llvm::CallInst *call, Explosion &out) override { void emitCallToUnmappedExplosion(llvm::CallInst *call, Explosion &out) override {
@@ -2018,20 +2043,13 @@ public:
// argument buffer. // argument buffer.
return; return;
} }
assert(call->arg_size() == 1);
auto context = call->arg_begin()->get();
// Gather the values. // Gather the values.
Explosion nativeExplosion; Explosion nativeExplosion;
auto layout = getAsyncContextLayout(); auto layout = getAsyncContextLayout();
auto dataAddr = layout.emitCastTo(IGF, context);
for (unsigned index = 0, count = layout.getDirectReturnCount(); for (unsigned index = 0, count = layout.getDirectReturnCount();
index < count; ++index) { index < count; ++index) {
auto fieldLayout = layout.getDirectReturnLayout(index); auto fieldLayout = layout.getDirectReturnLayout(index);
Address fieldAddr = loadValue(fieldLayout, nativeExplosion);
fieldLayout.project(IGF, dataAddr, /*offsets*/ llvm::None);
auto &fieldTI = fieldLayout.getType();
cast<LoadableTypeInfo>(fieldTI).loadAsTake(IGF, fieldAddr,
nativeExplosion);
} }
out = nativeSchema.mapFromNative(IGF.IGM, IGF, nativeExplosion, resultType); out = nativeSchema.mapFromNative(IGF.IGM, IGF, nativeExplosion, resultType);

View File

@@ -89,6 +89,7 @@ namespace irgen {
SILType type; SILType type;
ParameterConvention convention; ParameterConvention convention;
}; };
struct TrailingWitnessInfo {};
private: private:
enum class FixedIndex : unsigned { enum class FixedIndex : unsigned {
@@ -107,28 +108,59 @@ namespace irgen {
SmallVector<SILResultInfo, 4> indirectReturnInfos; SmallVector<SILResultInfo, 4> indirectReturnInfos;
Optional<ArgumentInfo> localContextInfo; Optional<ArgumentInfo> localContextInfo;
NecessaryBindings bindings; NecessaryBindings bindings;
Optional<TrailingWitnessInfo> trailingWitnessInfo;
SmallVector<ArgumentInfo, 4> argumentInfos; SmallVector<ArgumentInfo, 4> argumentInfos;
unsigned getErrorIndex() { return (unsigned)FixedIndex::Error; }
unsigned getFirstIndirectReturnIndex() {
return getErrorIndex() + getErrorCount();
}
unsigned getLocalContextIndex() {
assert(hasLocalContext());
return getFirstIndirectReturnIndex() + getIndirectReturnCount();
}
unsigned getIndexAfterLocalContext() {
return getFirstIndirectReturnIndex() + getIndirectReturnCount() +
(hasLocalContext() ? 1 : 0);
}
unsigned getBindingsIndex() {
assert(hasBindings());
return getIndexAfterLocalContext();
}
unsigned getIndexAfterBindings() {
return getIndexAfterLocalContext() + (hasBindings() ? 1 : 0);
}
unsigned getFirstArgumentIndex() { return getIndexAfterBindings(); }
unsigned getIndexAfterArguments() {
return getFirstArgumentIndex() + getArgumentCount();
}
unsigned getSelfMetadataIndex() {
assert(hasTrailingWitnesses());
return getIndexAfterArguments();
}
unsigned getSelfWitnessTableIndex() {
assert(hasTrailingWitnesses());
return getIndexAfterArguments() + 1;
}
unsigned getIndexAfterTrailingWitnesses() {
return getIndexAfterArguments() + (hasTrailingWitnesses() ? 2 : 0);
}
unsigned getFirstDirectReturnIndex() {
return getIndexAfterTrailingWitnesses();
}
public: public:
bool canHaveError() { return canHaveValidError; } bool canHaveError() { return canHaveValidError; }
unsigned getErrorIndex() { return (unsigned)FixedIndex::Error; }
ElementLayout getErrorLayout() { return getElement(getErrorIndex()); } ElementLayout getErrorLayout() { return getElement(getErrorIndex()); }
unsigned getErrorCount() { return (unsigned)FixedCount::Error; } unsigned getErrorCount() { return (unsigned)FixedCount::Error; }
SILType getErrorType() { return errorType; } SILType getErrorType() { return errorType; }
unsigned getFirstIndirectReturnIndex() {
return getErrorIndex() + getErrorCount();
}
ElementLayout getIndirectReturnLayout(unsigned index) { ElementLayout getIndirectReturnLayout(unsigned index) {
return getElement(getFirstIndirectReturnIndex() + index); return getElement(getFirstIndirectReturnIndex() + index);
} }
unsigned getIndirectReturnCount() { return indirectReturnInfos.size(); } unsigned getIndirectReturnCount() { return indirectReturnInfos.size(); }
bool hasLocalContext() { return (bool)localContextInfo; } bool hasLocalContext() { return (bool)localContextInfo; }
unsigned getLocalContextIndex() {
assert(hasLocalContext());
return getFirstIndirectReturnIndex() + getIndirectReturnCount();
}
ElementLayout getLocalContextLayout() { ElementLayout getLocalContextLayout() {
assert(hasLocalContext()); assert(hasLocalContext());
return getElement(getLocalContextIndex()); return getElement(getLocalContextIndex());
@@ -141,62 +173,50 @@ namespace irgen {
assert(hasLocalContext()); assert(hasLocalContext());
return localContextInfo->type; return localContextInfo->type;
} }
unsigned getIndexAfterLocalContext() {
return getFirstIndirectReturnIndex() + getIndirectReturnCount() +
(hasLocalContext() ? 1 : 0);
}
bool hasBindings() const { return !bindings.empty(); } bool hasBindings() const { return !bindings.empty(); }
unsigned getBindingsIndex() {
assert(hasBindings());
return getIndexAfterLocalContext();
}
ElementLayout getBindingsLayout() { ElementLayout getBindingsLayout() {
assert(hasBindings()); assert(hasBindings());
return getElement(getBindingsIndex()); return getElement(getBindingsIndex());
} }
ParameterConvention getBindingsConvention() {
return ParameterConvention::Direct_Unowned;
}
const NecessaryBindings &getBindings() const { return bindings; } const NecessaryBindings &getBindings() const { return bindings; }
unsigned getFirstArgumentIndex() {
return getIndexAfterLocalContext() + (hasBindings() ? 1 : 0);
}
ElementLayout getArgumentLayout(unsigned index) { ElementLayout getArgumentLayout(unsigned index) {
return getElement(getFirstArgumentIndex() + index); return getElement(getFirstArgumentIndex() + index);
} }
ParameterConvention getArgumentConvention(unsigned index) {
return argumentInfos[index].convention;
}
SILType getArgumentType(unsigned index) { SILType getArgumentType(unsigned index) {
return argumentInfos[index].type; return argumentInfos[index].type;
} }
// Returns the type of a parameter of the substituted function using the
// indexing of the function parameters, *not* the indexing of
// AsyncContextLayout.
SILType getParameterType(unsigned index) { SILType getParameterType(unsigned index) {
SILFunctionConventions origConv(substitutedType, IGF.getSILModule()); SILFunctionConventions origConv(substitutedType, IGF.getSILModule());
return origConv.getSILArgumentType( return origConv.getSILArgumentType(
index, IGF.IGM.getMaximalTypeExpansionContext()); index, IGF.IGM.getMaximalTypeExpansionContext());
} }
unsigned getArgumentCount() { return argumentInfos.size(); } unsigned getArgumentCount() { return argumentInfos.size(); }
unsigned getIndexAfterArguments() { bool hasTrailingWitnesses() { return (bool)trailingWitnessInfo; }
return getFirstArgumentIndex() + getArgumentCount(); ElementLayout getSelfMetadataLayout() {
assert(hasTrailingWitnesses());
return getElement(getSelfMetadataIndex());
}
ElementLayout getSelfWitnessTableLayout() {
return getElement(getSelfWitnessTableIndex());
} }
unsigned getFirstDirectReturnIndex() { return getIndexAfterArguments(); }
unsigned getDirectReturnCount() { return directReturnInfos.size(); } unsigned getDirectReturnCount() { return directReturnInfos.size(); }
ElementLayout getDirectReturnLayout(unsigned index) { ElementLayout getDirectReturnLayout(unsigned index) {
return getElement(getFirstDirectReturnIndex() + index); return getElement(getFirstDirectReturnIndex() + index);
} }
AsyncContextLayout(IRGenModule &IGM, LayoutStrategy strategy, AsyncContextLayout(
ArrayRef<SILType> fieldTypes, IRGenModule &IGM, LayoutStrategy strategy, ArrayRef<SILType> fieldTypes,
ArrayRef<const TypeInfo *> fieldTypeInfos, ArrayRef<const TypeInfo *> fieldTypeInfos, IRGenFunction &IGF,
IRGenFunction &IGF, CanSILFunctionType originalType, CanSILFunctionType originalType, CanSILFunctionType substitutedType,
CanSILFunctionType substitutedType, SubstitutionMap substitutionMap, NecessaryBindings &&bindings,
SubstitutionMap substitutionMap, Optional<TrailingWitnessInfo> trailingWitnessInfo, SILType errorType,
NecessaryBindings &&bindings, SILType errorType, bool canHaveValidError, ArrayRef<ArgumentInfo> argumentInfos,
bool canHaveValidError,
ArrayRef<ArgumentInfo> argumentInfos,
ArrayRef<SILResultInfo> directReturnInfos, ArrayRef<SILResultInfo> directReturnInfos,
ArrayRef<SILResultInfo> indirectReturnInfos, ArrayRef<SILResultInfo> indirectReturnInfos,
Optional<ArgumentInfo> localContextInfo); Optional<ArgumentInfo> localContextInfo);

View File

@@ -3100,7 +3100,11 @@ NecessaryBindings NecessaryBindings::computeBindings(
continue; continue;
case MetadataSource::Kind::SelfMetadata: case MetadataSource::Kind::SelfMetadata:
// Async functions pass the SelfMetadata and SelfWitnessTable parameters
// along explicitly.
if (forPartialApplyForwarder) {
bindings.addTypeMetadata(getSubstSelfType(IGM, origType, subs)); bindings.addTypeMetadata(getSubstSelfType(IGM, origType, subs));
}
continue; continue;
case MetadataSource::Kind::SelfWitnessTable: case MetadataSource::Kind::SelfWitnessTable:

View File

@@ -1221,6 +1221,14 @@ class AsyncNativeCCEntryPointArgumentEmission final
/*const*/ AsyncContextLayout layout; /*const*/ AsyncContextLayout layout;
const Address dataAddr; const Address dataAddr;
llvm::Value *loadValue(ElementLayout layout) {
Address addr = layout.project(IGF, dataAddr, /*offsets*/ llvm::None);
auto &ti = cast<LoadableTypeInfo>(layout.getType());
Explosion explosion;
ti.loadAsTake(IGF, addr, explosion);
return explosion.claimNext();
}
public: public:
AsyncNativeCCEntryPointArgumentEmission(IRGenSILFunction &IGF, AsyncNativeCCEntryPointArgumentEmission(IRGenSILFunction &IGF,
SILBasicBlock &entry, SILBasicBlock &entry,
@@ -1234,36 +1242,17 @@ public:
Address addr = errorLayout.project(IGF, dataAddr, /*offsets*/ llvm::None); Address addr = errorLayout.project(IGF, dataAddr, /*offsets*/ llvm::None);
return addr.getAddress(); return addr.getAddress();
} }
llvm::Value *getErrorResultAddrForCall() {
auto errorLayout = layout.getErrorLayout();
auto &ti = cast<LoadableTypeInfo>(errorLayout.getType());
auto allocaAddr = ti.allocateStack(IGF, layout.getErrorType(), "arg");
auto addrInContext =
layout.getErrorLayout().project(IGF, dataAddr, /*offsets*/ llvm::None);
Explosion explosion;
ti.loadAsTake(IGF, addrInContext, explosion);
ti.initialize(IGF, explosion, allocaAddr.getAddress(),
/*isOutlined*/ false);
return allocaAddr.getAddress().getAddress();
}
llvm::Value *getContext() override { llvm::Value *getContext() override {
auto contextLayout = layout.getLocalContextLayout(); auto contextLayout = layout.getLocalContextLayout();
Address addr = contextLayout.project(IGF, dataAddr, /*offsets*/ llvm::None); return loadValue(contextLayout);
auto &ti = cast<LoadableTypeInfo>(contextLayout.getType());
Explosion explosion;
ti.loadAsTake(IGF, addr, explosion);
return explosion.claimNext();
} }
Explosion getArgumentExplosion(unsigned index, unsigned size) override { Explosion getArgumentExplosion(unsigned index, unsigned size) override {
assert(size > 0); assert(size > 0);
Explosion result; Explosion result;
for (unsigned i = index, end = index + size; i < end; ++i) { for (unsigned i = index, end = index + size; i < end; ++i) {
auto argumentLayout = layout.getArgumentLayout(i); auto argumentLayout = layout.getArgumentLayout(i);
auto addr = argumentLayout.project(IGF, dataAddr, /*offsets*/ llvm::None); auto *value = loadValue(argumentLayout);
auto &ti = cast<LoadableTypeInfo>(argumentLayout.getType()); result.add(value);
Explosion explosion;
ti.loadAsTake(IGF, addr, explosion);
result.add(explosion.claimAll());
} }
return result; return result;
} }
@@ -1274,18 +1263,17 @@ public:
"indirected through the context"); "indirected through the context");
} }
llvm::Value *getIndirectResult(unsigned index) override { llvm::Value *getIndirectResult(unsigned index) override {
Address dataAddr = layout.emitCastTo(IGF, context); auto fieldLayout = layout.getIndirectReturnLayout(index);
unsigned baseIndirectReturnIndex = layout.getFirstIndirectReturnIndex(); return loadValue(fieldLayout);
unsigned elementIndex = baseIndirectReturnIndex + index;
auto &fieldLayout = layout.getElement(elementIndex);
Address fieldAddr =
fieldLayout.project(IGF, dataAddr, /*offsets*/ llvm::None);
return IGF.Builder.CreateLoad(fieldAddr);
}; };
llvm::Value *getSelfWitnessTable() override { llvm::Value *getSelfWitnessTable() override {
llvm_unreachable("unimplemented"); auto fieldLayout = layout.getSelfWitnessTableLayout();
return loadValue(fieldLayout);
}
llvm::Value *getSelfMetadata() override {
auto fieldLayout = layout.getSelfMetadataLayout();
return loadValue(fieldLayout);
} }
llvm::Value *getSelfMetadata() override { llvm_unreachable("unimplemented"); }
llvm::Value *getCoroutineBuffer() override { llvm::Value *getCoroutineBuffer() override {
llvm_unreachable("unimplemented"); llvm_unreachable("unimplemented");
} }
@@ -3115,16 +3103,13 @@ static void emitReturnInst(IRGenSILFunction &IGF,
auto layout = getAsyncContextLayout(IGF); auto layout = getAsyncContextLayout(IGF);
Address dataAddr = layout.emitCastTo(IGF, context); Address dataAddr = layout.emitCastTo(IGF, context);
unsigned index = layout.getFirstDirectReturnIndex(); for (unsigned index = 0, count = layout.getDirectReturnCount();
for (auto r : index < count; ++index) {
IGF.CurSILFn->getLoweredFunctionType()->getDirectFormalResults()) { auto fieldLayout = layout.getDirectReturnLayout(index);
(void)r;
auto &fieldLayout = layout.getElement(index);
Address fieldAddr = Address fieldAddr =
fieldLayout.project(IGF, dataAddr, /*offsets*/ llvm::None); fieldLayout.project(IGF, dataAddr, /*offsets*/ llvm::None);
cast<LoadableTypeInfo>(fieldLayout.getType()) cast<LoadableTypeInfo>(fieldLayout.getType())
.initialize(IGF, result, fieldAddr, /*isOutlined*/ false); .initialize(IGF, result, fieldAddr, /*isOutlined*/ false);
++index;
} }
IGF.Builder.CreateRetVoid(); IGF.Builder.CreateRetVoid();
} else { } else {

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none
@@ -35,7 +35,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
%out_addr = alloc_stack $Int64 %out_addr = alloc_stack $Int64
%genericToGeneric = function_ref @genericToGeneric : $@async @convention(thin) <T> (@in_guaranteed T) -> @out T %genericToGeneric = function_ref @genericToGeneric : $@async @convention(thin) <T> (@in_guaranteed T) -> @out T
%result1 = apply %genericToGeneric<Int64>(%int_addr, %out_addr) : $@async @convention(thin) <T> (@in_guaranteed T) -> @out T %result1 = apply %genericToGeneric<Int64>(%out_addr, %int_addr) : $@async @convention(thin) <T> (@in_guaranteed T) -> @out T
%print_int = function_ref @printInt64 : $@convention(thin) (Int64) -> () %print_int = function_ref @printInt64 : $@convention(thin) (Int64) -> ()
%out = load %out_addr : $*Int64 %out = load %out_addr : $*Int64

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -0,0 +1,73 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift-dylib(%t/%target-library-name(PrintShims)) %S/../../Inputs/print-shims.swift -module-name PrintShims -emit-module -emit-module-path %t/PrintShims.swiftmodule
// RUN: %target-codesign %t/%target-library-name(PrintShims)
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main
// RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none
// UNSUPPORTED: use_os_stdlib
import Builtin
import Swift
import PrintShims
sil public_external @printGeneric : $@convention(thin) <T> (@in_guaranteed T) -> ()
sil public_external @printInt64 : $@convention(thin) (Int64) -> ()
protocol P {
func printMe() async -> Int64
}
struct I : P {
@_hasStorage let int: Int64 { get }
func printMe() async -> Int64
init(int: Int64)
}
// CHECK-LL-LABEL: define hidden swiftcc void @I_printMe(%swift.context* {{%[0-9]*}}) {{#[0-9]*}} {
sil hidden @I_printMe : $@async @convention(method) (I) -> Int64 {
bb0(%self : $I):
%self_addr = alloc_stack $I
store %self to %self_addr : $*I
%printGeneric = function_ref @printGeneric : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
%printGeneric_result = apply %printGeneric<I>(%self_addr) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
dealloc_stack %self_addr : $*I
%result = struct_extract %self : $I, #I.int
return %result : $Int64
}
// CHECK-LL-LABEL: define internal swiftcc void @I_P_printMe(%swift.context* {{%[0-9]*}}) {{#[0-9]*}} {
sil private [transparent] [thunk] @I_P_printMe : $@async @convention(witness_method: P) (@in_guaranteed I) -> Int64 {
bb0(%self_addr : $*I):
%self = load %self_addr : $*I
%I_printMe = function_ref @I_printMe : $@async @convention(method) (I) -> Int64
%result = apply %I_printMe(%self) : $@async @convention(method) (I) -> Int64
return %result : $Int64
}
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
%i_type = metatype $@thin I.Type
%i_int_literal = integer_literal $Builtin.Int64, 99
%i_int = struct $Int64 (%i_int_literal : $Builtin.Int64)
%i = struct $I (%i_int : $Int64)
%i_addr = alloc_stack $I
store %i to %i_addr : $*I
%P_printMe = witness_method $I, #P.printMe : <Self where Self : P> (Self) -> () async -> Int64 : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int64
%result = apply %P_printMe<I>(%i_addr) : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int64 // CHECK: I(int: 99)
dealloc_stack %i_addr : $*I
%printInt64 = function_ref @printInt64 : $@convention(thin) (Int64) -> ()
%printInt64_result = apply %printInt64(%result) : $@convention(thin) (Int64) -> () // CHECK: 99
%out_literal = integer_literal $Builtin.Int32, 0
%out = struct $Int32 (%out_literal : $Builtin.Int32)
return %out : $Int32
}
sil_witness_table hidden I: P module main {
method #P.printMe: <Self where Self : P> (Self) -> () async -> Int64 : @I_P_printMe
}

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) // RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main // RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s // RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test // REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none // REQUIRES: swift_test_mode_optimize_none

View File

@@ -0,0 +1,97 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift-dylib(%t/%target-library-name(PrintShims)) %S/../../Inputs/print-shims.swift -module-name PrintShims -emit-module -emit-module-path %t/PrintShims.swiftmodule
// RUN: %target-codesign %t/%target-library-name(PrintShims)
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main
// RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none
// UNSUPPORTED: use_os_stdlib
import Builtin
import Swift
import PrintShims
sil public_external @printGeneric : $@convention(thin) <T> (@in_guaranteed T) -> ()
sil public_external @printInt64 : $@convention(thin) (Int64) -> ()
protocol P {
func printMe<T>(_ t: T) async -> (Int64, T)
}
extension P {
func callPrintMe<T>(_ t: T) async -> (Int64, T)
}
struct I : P {
@_hasStorage let int: Int64 { get }
func printMe<T>(_ t: T) async -> (Int64, T)
init(int: Int64)
}
sil hidden @I_printMe : $@convention(method) @async <T> (@in_guaranteed T, I) -> (Int64, @out T) {
bb0(%out_addr : $*T, %in_addr : $*T, %self : $I):
%self_addr = alloc_stack $I
store %self to %self_addr : $*I
%printGeneric = function_ref @printGeneric : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
%printGeneric_result = apply %printGeneric<I>(%self_addr) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
dealloc_stack %self_addr : $*I
%value = struct_extract %self : $I, #I.int
copy_addr %in_addr to [initialization] %out_addr : $*T
return %value : $Int64
}
// CHECK-LL: define internal swiftcc void @I_P_printMe(%swift.context* {{%[0-9]*}}) {{#[0-9]*}} {
sil private [transparent] [thunk] @I_P_printMe : $@convention(witness_method: P) @async <τ_0_0> (@in_guaranteed τ_0_0, @in_guaranteed I) -> (Int64, @out τ_0_0) {
bb0(%out_addr : $*τ_0_0, %in_addr : $*τ_0_0, %self_addr : $*I):
%self = load %self_addr : $*I
%I_printMe = function_ref @I_printMe : $@convention(method) @async <τ_0_0> (@in_guaranteed τ_0_0, I) -> (Int64, @out τ_0_0)
%result = apply %I_printMe<τ_0_0>(%out_addr, %in_addr, %self) : $@convention(method) @async <τ_0_0> (@in_guaranteed τ_0_0, I) -> (Int64, @out τ_0_0)
return %result : $Int64
}
sil hidden @callPrintMe : $@convention(thin) <T, U where T : P> (@in_guaranteed T, @in_guaranteed U) -> (Int64, @out U) {
bb0(%out_addr : $*U, %self_addr : $*T, %in_addr : $*U):
%I_P_printMe = witness_method $T, #P.printMe : <Self where Self : P><T> (Self) -> (T) async -> (Int64, T) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P><τ_1_0> (@in_guaranteed τ_1_0, @in_guaranteed τ_0_0) -> (Int64, @out τ_1_0)
%result = apply %I_P_printMe<T, U>(%out_addr, %in_addr, %self_addr) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P><τ_1_0> (@in_guaranteed τ_1_0, @in_guaranteed τ_0_0) -> (Int64, @out τ_1_0)
return %result : $Int64
}
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%argc : $Int32, %argv : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
%I_type = metatype $@thin I.Type
%int_literal = integer_literal $Builtin.Int64, 99
%int = struct $Int64 (%int_literal : $Builtin.Int64)
%i = struct $I (%int : $Int64)
%out_addr = alloc_stack $I
%in_addr = alloc_stack $I
store %i to %in_addr : $*I
%i_addr = alloc_stack $I
store %i to %i_addr : $*I
%callPrintMe = function_ref @callPrintMe : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_0 : P> (@in_guaranteed τ_0_0, @in_guaranteed τ_0_1) -> (Int64, @out τ_0_1)
%result = apply %callPrintMe<I, I>(%out_addr, %in_addr, %i_addr) : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_0 : P> (@in_guaranteed τ_0_0, @in_guaranteed τ_0_1) -> (Int64, @out τ_0_1)
dealloc_stack %i_addr : $*I
dealloc_stack %in_addr : $*I
%out = load %out_addr : $*I
dealloc_stack %out_addr : $*I
%printInt64 = function_ref @printInt64 : $@convention(thin) (Int64) -> ()
%printInt64_result = apply %printInt64(%result) : $@convention(thin) (Int64) -> () // CHECK: 99
%out_addr_2 = alloc_stack $I
store %out to %out_addr_2 : $*I
%printGeneric = function_ref @printGeneric : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
%printGeneric_result = apply %printGeneric<I>(%out_addr_2) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> () // CHECK: I(int: 99)
dealloc_stack %out_addr_2 : $*I
%returnCode_literal = integer_literal $Builtin.Int32, 0
%returnCode = struct $Int32 (%returnCode_literal : $Builtin.Int32)
return %returnCode : $Int32
}
sil_witness_table hidden I: P module main {
method #P.printMe: <Self where Self : P><T> (Self) -> (T) async -> (Int64, T) : @I_P_printMe
}

View File

@@ -0,0 +1,80 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift-dylib(%t/%target-library-name(PrintShims)) %S/../../Inputs/print-shims.swift -module-name PrintShims -emit-module -emit-module-path %t/PrintShims.swiftmodule
// RUN: %target-codesign %t/%target-library-name(PrintShims)
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
// RUN: %target-codesign %t/main
// RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s
// REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize_none
// UNSUPPORTED: use_os_stdlib
import Builtin
import Swift
import PrintShims
sil public_external @printGeneric : $@convention(thin) <T> (@in_guaranteed T) -> ()
sil public_external @printInt64 : $@convention(thin) (Int64) -> ()
protocol P {
func printMe() async -> Int64
}
struct I : P {
@_hasStorage let int: Int64 { get }
func printMe() async -> Int64
init(int: Int64)
}
// CHECK-LL-LABEL: define hidden swiftcc void @I_printMe(%swift.context* {{%[0-9]*}}) {{#[0-9]*}} {
sil hidden @I_printMe : $@async @convention(method) (I) -> Int64 {
bb0(%self : $I):
%self_addr = alloc_stack $I
store %self to %self_addr : $*I
%printGeneric = function_ref @printGeneric : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
%printGeneric_result = apply %printGeneric<I>(%self_addr) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
dealloc_stack %self_addr : $*I
%result = struct_extract %self : $I, #I.int
return %result : $Int64
}
// CHECK-LL-LABEL: define internal swiftcc void @I_P_printMe(%swift.context* {{%[0-9]*}}) {{#[0-9]*}} {
sil private [transparent] [thunk] @I_P_printMe : $@async @convention(witness_method: P) (@in_guaranteed I) -> Int64 {
bb0(%self_addr : $*I):
%self = load %self_addr : $*I
%I_printMe = function_ref @I_printMe : $@async @convention(method) (I) -> Int64
%result = apply %I_printMe(%self) : $@async @convention(method) (I) -> Int64
return %result : $Int64
}
sil hidden @callPrintMe : $@convention(thin) <T where T : P> (@in_guaranteed T) -> Int64 {
bb0(%t : $*T):
%I_P_printMe = witness_method $T, #P.printMe : <Self where Self : P> (Self) -> () async -> Int64 : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int64
%result = apply %I_P_printMe<T>(%t) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int64
return %result : $Int64
}
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
%i_type = metatype $@thin I.Type
%i_int_literal = integer_literal $Builtin.Int64, 99
%i_int = struct $Int64 (%i_int_literal : $Builtin.Int64)
%i = struct $I (%i_int : $Int64)
%i_addr = alloc_stack $I
store %i to %i_addr : $*I
%callPrintMe = function_ref @callPrintMe : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int64
%result = apply %callPrintMe<I>(%i_addr) : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int64 // users: %13, %11 // CHECK: I(int: 99)
dealloc_stack %i_addr : $*I
%printInt64 = function_ref @printInt64 : $@convention(thin) (Int64) -> ()
%printInt64_result = apply %printInt64(%result) : $@convention(thin) (Int64) -> () // CHECK: 99
%out_literal = integer_literal $Builtin.Int32, 0
%out = struct $Int32 (%out_literal : $Builtin.Int32)
return %out : $Int32
}
sil_witness_table hidden I: P module main {
method #P.printMe: <Self where Self : P> (Self) -> () async -> Int64 : @I_P_printMe
}