Skip to content

Commit 63ae329

Browse files
Merge pull request swiftlang#36489 from aschwaighofer/remove_error_from_async_context
Remove unused error result storage from AsyncContext
2 parents 6927a7f + 249b276 commit 63ae329

File tree

3 files changed

+5
-31
lines changed

3 files changed

+5
-31
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,6 @@ irgen::getAsyncContextLayout(IRGenModule &IGM, CanSILFunctionType originalType,
146146
typeInfos.push_back(&ti);
147147
}
148148

149-
// SwiftError **errorResult;
150-
auto errorCanType = IGM.Context.getExceptionType();
151-
auto errorType = SILType::getPrimitiveObjectType(errorCanType);
152-
auto &errorTypeInfo =
153-
IGM.getTypeInfoForLowered(CanInOutType::get(errorCanType));
154-
typeInfos.push_back(&errorTypeInfo);
155-
valTypes.push_back(errorType);
156149
// Add storage for data used by runtime entry points.
157150
// See TaskFutureWaitAsyncContext.
158151
if (kind.isSpecial()) {
@@ -196,22 +189,18 @@ irgen::getAsyncContextLayout(IRGenModule &IGM, CanSILFunctionType originalType,
196189
} break;
197190
}
198191
}
199-
bool canHaveValidError = substitutedType->hasErrorResult();
200192
return AsyncContextLayout(IGM, LayoutStrategy::Optimal, valTypes, typeInfos,
201-
originalType, substitutedType, substitutionMap,
202-
errorType, canHaveValidError);
193+
originalType, substitutedType, substitutionMap);
203194
}
204195

205196
AsyncContextLayout::AsyncContextLayout(
206197
IRGenModule &IGM, LayoutStrategy strategy, ArrayRef<SILType> fieldTypes,
207198
ArrayRef<const TypeInfo *> fieldTypeInfos, CanSILFunctionType originalType,
208-
CanSILFunctionType substitutedType, SubstitutionMap substitutionMap,
209-
SILType errorType, bool canHaveValidError)
199+
CanSILFunctionType substitutedType, SubstitutionMap substitutionMap)
210200
: StructLayout(IGM, /*decl=*/nullptr, LayoutKind::NonHeapObject, strategy,
211201
fieldTypeInfos, /*typeToFill*/ nullptr),
212202
originalType(originalType), substitutedType(substitutedType),
213-
substitutionMap(substitutionMap), errorType(errorType),
214-
canHaveValidError(canHaveValidError) {
203+
substitutionMap(substitutionMap) {
215204
#ifndef NDEBUG
216205
assert(fieldTypeInfos.size() == fieldTypes.size() &&
217206
"type infos don't match types");
@@ -2317,13 +2306,6 @@ class AsyncCallEmission final : public CallEmission {
23172306
IGF.Builder.CreateZExt(dynamicContextSize32, IGF.IGM.SizeTy);
23182307
contextBuffer = emitAllocAsyncContext(IGF, dynamicContextSize);
23192308
context = layout.emitCastTo(IGF, contextBuffer.getAddress());
2320-
if (layout.canHaveError()) {
2321-
auto fieldLayout = layout.getErrorLayout();
2322-
auto ptrToAddr =
2323-
fieldLayout.project(IGF, context, /*offsets*/ llvm::None);
2324-
auto errorSlot = IGF.getAsyncCalleeErrorResultSlot(layout.getErrorType());
2325-
IGF.Builder.CreateStore(errorSlot.getAddress(), ptrToAddr);
2326-
}
23272309
}
23282310
void end() override {
23292311
assert(contextBuffer.isValid());

lib/IRGen/GenCall.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ namespace irgen {
7171
// SwiftPartialFunction * __ptrauth(...) returnToCaller;
7272
// SwiftActor * __ptrauth(...) callerActor;
7373
// SwiftPartialFunction * __ptrauth(...) yieldToCaller?;
74-
// SwiftError **errorResult;
7574
// };
7675
struct AsyncContextLayout : StructLayout {
7776
struct ArgumentInfo {
@@ -91,13 +90,10 @@ namespace irgen {
9190
Parent = 1,
9291
ResumeParent = 1,
9392
ResumeParentExecutor = 1,
94-
Error = 1,
9593
};
9694
CanSILFunctionType originalType;
9795
CanSILFunctionType substitutedType;
9896
SubstitutionMap substitutionMap;
99-
SILType errorType;
100-
bool canHaveValidError;
10197

10298
unsigned getParentIndex() { return (unsigned)FixedIndex::Parent; }
10399
unsigned getResumeParentIndex() {
@@ -120,16 +116,12 @@ namespace irgen {
120116
return getElement(getResumeParentExecutorIndex());
121117
}
122118
ElementLayout getFlagsLayout() { return getElement(getFlagsIndex()); }
123-
bool canHaveError() { return canHaveValidError; }
124-
ElementLayout getErrorLayout() { return getElement(getErrorIndex()); }
125-
unsigned getErrorCount() { return (unsigned)FixedCount::Error; }
126-
SILType getErrorType() { return errorType; }
127119

128120
AsyncContextLayout(
129121
IRGenModule &IGM, LayoutStrategy strategy, ArrayRef<SILType> fieldTypes,
130122
ArrayRef<const TypeInfo *> fieldTypeInfos,
131123
CanSILFunctionType originalType, CanSILFunctionType substitutedType,
132-
SubstitutionMap substitutionMap, SILType errorType, bool canHaveValidError);
124+
SubstitutionMap substitutionMap);
133125
};
134126

135127
AsyncContextLayout getAsyncContextLayout(IRGenModule &IGM,

test/IRGen/async.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class SomeClass {}
1717
public func task_future_wait(_ task: __owned SomeClass) async throws -> Int
1818

1919
// CHECK: define{{.*}} swift{{(tail)?}}cc void @"$s5async8testThisyyAA9SomeClassCnYF"(%swift.context* swiftasync %0{{.*}}
20-
// CHECK-64: call swiftcc i8* @swift_task_alloc(i64 64)
20+
// CHECK-64: call swiftcc i8* @swift_task_alloc(i64 56)
2121
// CHECK: {{(must)?}}tail call swift{{(tail)?}}cc void @swift_task_future_wait(
2222
public func testThis(_ task: __owned SomeClass) async {
2323
do {

0 commit comments

Comments
 (0)