mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge remote-tracking branch 'origin/main' into next
This commit is contained in:
@@ -127,7 +127,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class CompileJobAction : public JobAction {
|
||||
class IncrementalJobAction : public JobAction {
|
||||
public:
|
||||
struct InputInfo {
|
||||
enum Status {
|
||||
@@ -136,6 +136,8 @@ public:
|
||||
NeedsNonCascadingBuild,
|
||||
NewlyAdded
|
||||
};
|
||||
|
||||
public:
|
||||
Status status = UpToDate;
|
||||
llvm::sys::TimePoint<> previousModTime;
|
||||
|
||||
@@ -153,18 +155,32 @@ private:
|
||||
InputInfo inputInfo;
|
||||
|
||||
public:
|
||||
CompileJobAction(file_types::ID OutputType)
|
||||
: JobAction(Action::Kind::CompileJob, None, OutputType),
|
||||
inputInfo() {}
|
||||
|
||||
CompileJobAction(Action *Input, file_types::ID OutputType, InputInfo info)
|
||||
: JobAction(Action::Kind::CompileJob, Input, OutputType),
|
||||
inputInfo(info) {}
|
||||
IncrementalJobAction(Kind Kind, ArrayRef<const Action *> Inputs,
|
||||
file_types::ID Type, InputInfo info)
|
||||
: JobAction(Kind, Inputs, Type), inputInfo(info) {}
|
||||
|
||||
public:
|
||||
InputInfo getInputInfo() const {
|
||||
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) {
|
||||
return A->getKind() == Action::Kind::CompileJob;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ void InputAction::anchor() {}
|
||||
|
||||
void JobAction::anchor() {}
|
||||
|
||||
void IncrementalJobAction::anchor() {}
|
||||
|
||||
void CompileJobAction::anchor() {}
|
||||
|
||||
void InterpretJobAction::anchor() {}
|
||||
|
||||
@@ -860,7 +860,7 @@ namespace driver {
|
||||
computeFirstRoundCompileJobsForIncrementalCompilation();
|
||||
|
||||
for (const Job *Cmd : Comp.getJobs()) {
|
||||
if (Cmd->getFirstSwiftPrimaryInput().empty() ||
|
||||
if (!isa<IncrementalJobAction>(Cmd->getSource()) ||
|
||||
compileJobsToSchedule.count(Cmd)) {
|
||||
scheduleCommandIfNecessaryAndPossible(Cmd);
|
||||
noteBuilding(Cmd, /*willBeBuilding*/ true, /*isTentative=*/false,
|
||||
@@ -899,20 +899,22 @@ namespace driver {
|
||||
CommandSet
|
||||
computeDependenciesAndGetNeededCompileJobs(const bool forRanges) {
|
||||
auto getEveryCompileJob = [&] {
|
||||
CommandSet everyCompileJob;
|
||||
CommandSet everyIncrementalJob;
|
||||
for (const Job *Cmd : Comp.getJobs()) {
|
||||
if (!Cmd->getFirstSwiftPrimaryInput().empty())
|
||||
everyCompileJob.insert(Cmd);
|
||||
if (isa<IncrementalJobAction>(Cmd->getSource()))
|
||||
everyIncrementalJob.insert(Cmd);
|
||||
}
|
||||
return everyCompileJob;
|
||||
return everyIncrementalJob;
|
||||
};
|
||||
|
||||
CommandSet jobsToSchedule;
|
||||
CommandSet initialCascadingCommands;
|
||||
for (const Job *cmd : Comp.getJobs()) {
|
||||
const StringRef primary = cmd->getFirstSwiftPrimaryInput();
|
||||
if (primary.empty())
|
||||
continue; // not Compile
|
||||
// Skip jobs that have no associated incremental info.
|
||||
if (!isa<IncrementalJobAction>(cmd->getSource())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const Optional<std::pair<bool, bool>> shouldSchedAndIsCascading =
|
||||
computeShouldInitiallyScheduleJobAndDependendents(cmd, forRanges);
|
||||
if (!shouldSchedAndIsCascading)
|
||||
|
||||
@@ -181,6 +181,28 @@ AsyncContextLayout irgen::getAsyncContextLayout(
|
||||
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...;
|
||||
auto directResults = fnConv.getDirectSILResults();
|
||||
for (auto result : directResults) {
|
||||
@@ -192,11 +214,11 @@ AsyncContextLayout irgen::getAsyncContextLayout(
|
||||
directReturnInfos.push_back(result);
|
||||
}
|
||||
|
||||
return AsyncContextLayout(IGF.IGM, LayoutStrategy::Optimal, valTypes,
|
||||
typeInfos, IGF, originalType, substitutedType,
|
||||
substitutionMap, std::move(bindings), errorType,
|
||||
canHaveValidError, paramInfos, indirectReturnInfos,
|
||||
directReturnInfos, localContextInfo);
|
||||
return AsyncContextLayout(
|
||||
IGF.IGM, LayoutStrategy::Optimal, valTypes, typeInfos, IGF, originalType,
|
||||
substitutedType, substitutionMap, std::move(bindings),
|
||||
trailingWitnessInfo, errorType, canHaveValidError, paramInfos,
|
||||
indirectReturnInfos, directReturnInfos, localContextInfo);
|
||||
}
|
||||
|
||||
AsyncContextLayout::AsyncContextLayout(
|
||||
@@ -204,8 +226,8 @@ AsyncContextLayout::AsyncContextLayout(
|
||||
ArrayRef<const TypeInfo *> fieldTypeInfos, IRGenFunction &IGF,
|
||||
CanSILFunctionType originalType, CanSILFunctionType substitutedType,
|
||||
SubstitutionMap substitutionMap, NecessaryBindings &&bindings,
|
||||
SILType errorType, bool canHaveValidError,
|
||||
ArrayRef<ArgumentInfo> argumentInfos,
|
||||
Optional<TrailingWitnessInfo> trailingWitnessInfo, SILType errorType,
|
||||
bool canHaveValidError, ArrayRef<ArgumentInfo> argumentInfos,
|
||||
ArrayRef<SILResultInfo> indirectReturnInfos,
|
||||
ArrayRef<SILResultInfo> directReturnInfos,
|
||||
Optional<AsyncContextLayout::ArgumentInfo> localContextInfo)
|
||||
@@ -218,6 +240,7 @@ AsyncContextLayout::AsyncContextLayout(
|
||||
indirectReturnInfos(indirectReturnInfos.begin(),
|
||||
indirectReturnInfos.end()),
|
||||
localContextInfo(localContextInfo), bindings(std::move(bindings)),
|
||||
trailingWitnessInfo(trailingWitnessInfo),
|
||||
argumentInfos(argumentInfos.begin(), argumentInfos.end()) {
|
||||
#ifndef NDEBUG
|
||||
assert(fieldTypeInfos.size() == fieldTypes.size() &&
|
||||
@@ -1931,6 +1954,17 @@ class AsyncCallEmission final : public CallEmission {
|
||||
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:
|
||||
AsyncCallEmission(IRGenFunction &IGF, llvm::Value *selfValue, Callee &&callee)
|
||||
: CallEmission(IGF, selfValue, std::move(callee)) {
|
||||
@@ -1976,21 +2010,15 @@ public:
|
||||
llArgs.add(selfValue);
|
||||
}
|
||||
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();
|
||||
index < count; ++index) {
|
||||
auto fieldLayout = layout.getIndirectReturnLayout(index);
|
||||
Address fieldAddr =
|
||||
fieldLayout.project(IGF, context, /*offsets*/ llvm::None);
|
||||
cast<LoadableTypeInfo>(fieldLayout.getType())
|
||||
.initialize(IGF, llArgs, fieldAddr, isOutlined);
|
||||
saveValue(fieldLayout, llArgs, isOutlined);
|
||||
}
|
||||
for (unsigned index = 0, count = layout.getArgumentCount(); index < count;
|
||||
++index) {
|
||||
auto fieldLayout = layout.getArgumentLayout(index);
|
||||
saveValue(fieldLayout, llArgs, isOutlined);
|
||||
}
|
||||
if (layout.hasBindings()) {
|
||||
auto bindingLayout = layout.getBindingsLayout();
|
||||
@@ -1999,10 +2027,7 @@ public:
|
||||
}
|
||||
if (selfValue) {
|
||||
auto fieldLayout = layout.getLocalContextLayout();
|
||||
Address fieldAddr =
|
||||
fieldLayout.project(IGF, context, /*offsets*/ llvm::None);
|
||||
auto &ti = cast<LoadableTypeInfo>(fieldLayout.getType());
|
||||
ti.initialize(IGF, llArgs, fieldAddr, isOutlined);
|
||||
saveValue(fieldLayout, llArgs, isOutlined);
|
||||
}
|
||||
}
|
||||
void emitCallToUnmappedExplosion(llvm::CallInst *call, Explosion &out) override {
|
||||
@@ -2018,20 +2043,13 @@ public:
|
||||
// argument buffer.
|
||||
return;
|
||||
}
|
||||
assert(call->arg_size() == 1);
|
||||
auto context = call->arg_begin()->get();
|
||||
// Gather the values.
|
||||
Explosion nativeExplosion;
|
||||
auto layout = getAsyncContextLayout();
|
||||
auto dataAddr = layout.emitCastTo(IGF, context);
|
||||
for (unsigned index = 0, count = layout.getDirectReturnCount();
|
||||
index < count; ++index) {
|
||||
auto fieldLayout = layout.getDirectReturnLayout(index);
|
||||
Address fieldAddr =
|
||||
fieldLayout.project(IGF, dataAddr, /*offsets*/ llvm::None);
|
||||
auto &fieldTI = fieldLayout.getType();
|
||||
cast<LoadableTypeInfo>(fieldTI).loadAsTake(IGF, fieldAddr,
|
||||
nativeExplosion);
|
||||
loadValue(fieldLayout, nativeExplosion);
|
||||
}
|
||||
|
||||
out = nativeSchema.mapFromNative(IGF.IGM, IGF, nativeExplosion, resultType);
|
||||
|
||||
@@ -89,6 +89,7 @@ namespace irgen {
|
||||
SILType type;
|
||||
ParameterConvention convention;
|
||||
};
|
||||
struct TrailingWitnessInfo {};
|
||||
|
||||
private:
|
||||
enum class FixedIndex : unsigned {
|
||||
@@ -107,28 +108,59 @@ namespace irgen {
|
||||
SmallVector<SILResultInfo, 4> indirectReturnInfos;
|
||||
Optional<ArgumentInfo> localContextInfo;
|
||||
NecessaryBindings bindings;
|
||||
Optional<TrailingWitnessInfo> trailingWitnessInfo;
|
||||
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:
|
||||
bool canHaveError() { return canHaveValidError; }
|
||||
unsigned getErrorIndex() { return (unsigned)FixedIndex::Error; }
|
||||
ElementLayout getErrorLayout() { return getElement(getErrorIndex()); }
|
||||
unsigned getErrorCount() { return (unsigned)FixedCount::Error; }
|
||||
SILType getErrorType() { return errorType; }
|
||||
|
||||
unsigned getFirstIndirectReturnIndex() {
|
||||
return getErrorIndex() + getErrorCount();
|
||||
}
|
||||
ElementLayout getIndirectReturnLayout(unsigned index) {
|
||||
return getElement(getFirstIndirectReturnIndex() + index);
|
||||
}
|
||||
unsigned getIndirectReturnCount() { return indirectReturnInfos.size(); }
|
||||
|
||||
bool hasLocalContext() { return (bool)localContextInfo; }
|
||||
unsigned getLocalContextIndex() {
|
||||
assert(hasLocalContext());
|
||||
return getFirstIndirectReturnIndex() + getIndirectReturnCount();
|
||||
}
|
||||
ElementLayout getLocalContextLayout() {
|
||||
assert(hasLocalContext());
|
||||
return getElement(getLocalContextIndex());
|
||||
@@ -141,65 +173,53 @@ namespace irgen {
|
||||
assert(hasLocalContext());
|
||||
return localContextInfo->type;
|
||||
}
|
||||
unsigned getIndexAfterLocalContext() {
|
||||
return getFirstIndirectReturnIndex() + getIndirectReturnCount() +
|
||||
(hasLocalContext() ? 1 : 0);
|
||||
}
|
||||
|
||||
bool hasBindings() const { return !bindings.empty(); }
|
||||
unsigned getBindingsIndex() {
|
||||
assert(hasBindings());
|
||||
return getIndexAfterLocalContext();
|
||||
}
|
||||
ElementLayout getBindingsLayout() {
|
||||
assert(hasBindings());
|
||||
return getElement(getBindingsIndex());
|
||||
}
|
||||
ParameterConvention getBindingsConvention() {
|
||||
return ParameterConvention::Direct_Unowned;
|
||||
}
|
||||
const NecessaryBindings &getBindings() const { return bindings; }
|
||||
|
||||
unsigned getFirstArgumentIndex() {
|
||||
return getIndexAfterLocalContext() + (hasBindings() ? 1 : 0);
|
||||
}
|
||||
ElementLayout getArgumentLayout(unsigned index) {
|
||||
return getElement(getFirstArgumentIndex() + index);
|
||||
}
|
||||
ParameterConvention getArgumentConvention(unsigned index) {
|
||||
return argumentInfos[index].convention;
|
||||
}
|
||||
SILType getArgumentType(unsigned index) {
|
||||
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) {
|
||||
SILFunctionConventions origConv(substitutedType, IGF.getSILModule());
|
||||
return origConv.getSILArgumentType(
|
||||
index, IGF.IGM.getMaximalTypeExpansionContext());
|
||||
}
|
||||
unsigned getArgumentCount() { return argumentInfos.size(); }
|
||||
unsigned getIndexAfterArguments() {
|
||||
return getFirstArgumentIndex() + getArgumentCount();
|
||||
bool hasTrailingWitnesses() { return (bool)trailingWitnessInfo; }
|
||||
ElementLayout getSelfMetadataLayout() {
|
||||
assert(hasTrailingWitnesses());
|
||||
return getElement(getSelfMetadataIndex());
|
||||
}
|
||||
ElementLayout getSelfWitnessTableLayout() {
|
||||
return getElement(getSelfWitnessTableIndex());
|
||||
}
|
||||
|
||||
unsigned getFirstDirectReturnIndex() { return getIndexAfterArguments(); }
|
||||
unsigned getDirectReturnCount() { return directReturnInfos.size(); }
|
||||
ElementLayout getDirectReturnLayout(unsigned index) {
|
||||
return getElement(getFirstDirectReturnIndex() + index);
|
||||
}
|
||||
|
||||
AsyncContextLayout(IRGenModule &IGM, LayoutStrategy strategy,
|
||||
ArrayRef<SILType> fieldTypes,
|
||||
ArrayRef<const TypeInfo *> fieldTypeInfos,
|
||||
IRGenFunction &IGF, CanSILFunctionType originalType,
|
||||
CanSILFunctionType substitutedType,
|
||||
SubstitutionMap substitutionMap,
|
||||
NecessaryBindings &&bindings, SILType errorType,
|
||||
bool canHaveValidError,
|
||||
ArrayRef<ArgumentInfo> argumentInfos,
|
||||
ArrayRef<SILResultInfo> directReturnInfos,
|
||||
ArrayRef<SILResultInfo> indirectReturnInfos,
|
||||
Optional<ArgumentInfo> localContextInfo);
|
||||
AsyncContextLayout(
|
||||
IRGenModule &IGM, LayoutStrategy strategy, ArrayRef<SILType> fieldTypes,
|
||||
ArrayRef<const TypeInfo *> fieldTypeInfos, IRGenFunction &IGF,
|
||||
CanSILFunctionType originalType, CanSILFunctionType substitutedType,
|
||||
SubstitutionMap substitutionMap, NecessaryBindings &&bindings,
|
||||
Optional<TrailingWitnessInfo> trailingWitnessInfo, SILType errorType,
|
||||
bool canHaveValidError, ArrayRef<ArgumentInfo> argumentInfos,
|
||||
ArrayRef<SILResultInfo> directReturnInfos,
|
||||
ArrayRef<SILResultInfo> indirectReturnInfos,
|
||||
Optional<ArgumentInfo> localContextInfo);
|
||||
};
|
||||
|
||||
AsyncContextLayout getAsyncContextLayout(IRGenFunction &IGF,
|
||||
|
||||
@@ -3100,7 +3100,11 @@ NecessaryBindings NecessaryBindings::computeBindings(
|
||||
continue;
|
||||
|
||||
case MetadataSource::Kind::SelfMetadata:
|
||||
bindings.addTypeMetadata(getSubstSelfType(IGM, origType, subs));
|
||||
// Async functions pass the SelfMetadata and SelfWitnessTable parameters
|
||||
// along explicitly.
|
||||
if (forPartialApplyForwarder) {
|
||||
bindings.addTypeMetadata(getSubstSelfType(IGM, origType, subs));
|
||||
}
|
||||
continue;
|
||||
|
||||
case MetadataSource::Kind::SelfWitnessTable:
|
||||
|
||||
@@ -1221,6 +1221,14 @@ class AsyncNativeCCEntryPointArgumentEmission final
|
||||
/*const*/ AsyncContextLayout layout;
|
||||
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:
|
||||
AsyncNativeCCEntryPointArgumentEmission(IRGenSILFunction &IGF,
|
||||
SILBasicBlock &entry,
|
||||
@@ -1234,36 +1242,17 @@ public:
|
||||
Address addr = errorLayout.project(IGF, dataAddr, /*offsets*/ llvm::None);
|
||||
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 {
|
||||
auto contextLayout = layout.getLocalContextLayout();
|
||||
Address addr = contextLayout.project(IGF, dataAddr, /*offsets*/ llvm::None);
|
||||
auto &ti = cast<LoadableTypeInfo>(contextLayout.getType());
|
||||
Explosion explosion;
|
||||
ti.loadAsTake(IGF, addr, explosion);
|
||||
return explosion.claimNext();
|
||||
return loadValue(contextLayout);
|
||||
}
|
||||
Explosion getArgumentExplosion(unsigned index, unsigned size) override {
|
||||
assert(size > 0);
|
||||
Explosion result;
|
||||
for (unsigned i = index, end = index + size; i < end; ++i) {
|
||||
auto argumentLayout = layout.getArgumentLayout(i);
|
||||
auto addr = argumentLayout.project(IGF, dataAddr, /*offsets*/ llvm::None);
|
||||
auto &ti = cast<LoadableTypeInfo>(argumentLayout.getType());
|
||||
Explosion explosion;
|
||||
ti.loadAsTake(IGF, addr, explosion);
|
||||
result.add(explosion.claimAll());
|
||||
auto *value = loadValue(argumentLayout);
|
||||
result.add(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1274,18 +1263,17 @@ public:
|
||||
"indirected through the context");
|
||||
}
|
||||
llvm::Value *getIndirectResult(unsigned index) override {
|
||||
Address dataAddr = layout.emitCastTo(IGF, context);
|
||||
unsigned baseIndirectReturnIndex = layout.getFirstIndirectReturnIndex();
|
||||
unsigned elementIndex = baseIndirectReturnIndex + index;
|
||||
auto &fieldLayout = layout.getElement(elementIndex);
|
||||
Address fieldAddr =
|
||||
fieldLayout.project(IGF, dataAddr, /*offsets*/ llvm::None);
|
||||
return IGF.Builder.CreateLoad(fieldAddr);
|
||||
auto fieldLayout = layout.getIndirectReturnLayout(index);
|
||||
return loadValue(fieldLayout);
|
||||
};
|
||||
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_unreachable("unimplemented");
|
||||
}
|
||||
@@ -3115,16 +3103,13 @@ static void emitReturnInst(IRGenSILFunction &IGF,
|
||||
auto layout = getAsyncContextLayout(IGF);
|
||||
|
||||
Address dataAddr = layout.emitCastTo(IGF, context);
|
||||
unsigned index = layout.getFirstDirectReturnIndex();
|
||||
for (auto r :
|
||||
IGF.CurSILFn->getLoweredFunctionType()->getDirectFormalResults()) {
|
||||
(void)r;
|
||||
auto &fieldLayout = layout.getElement(index);
|
||||
for (unsigned index = 0, count = layout.getDirectReturnCount();
|
||||
index < count; ++index) {
|
||||
auto fieldLayout = layout.getDirectReturnLayout(index);
|
||||
Address fieldAddr =
|
||||
fieldLayout.project(IGF, dataAddr, /*offsets*/ llvm::None);
|
||||
cast<LoadableTypeInfo>(fieldLayout.getType())
|
||||
.initialize(IGF, result, fieldAddr, /*isOutlined*/ false);
|
||||
++index;
|
||||
}
|
||||
IGF.Builder.CreateRetVoid();
|
||||
} else {
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
@@ -35,7 +35,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
%out_addr = alloc_stack $Int64
|
||||
|
||||
%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) -> ()
|
||||
%out = load %out_addr : $*Int64
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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 -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t)
|
||||
// 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: swift_test_mode_optimize_none
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user