Skip to content

Commit 13cca95

Browse files
author
tnowicki
committed
[Coroutines][Swift] Remove replaceSwiftErrorOps while cloning
I am confused by what replaceSwiftErrorOps is supposed to do and it doesn't seem to be well covered by lit-tests. At least in tree. The function appears to primarily operate on the original function, because it processes the SwiftErrorOps in Shape, collected from the unsplit function. However, it is called during cloning process of each resume function and from reading the code it seems to do something strange. After cloning the first resume funnction it may add Load and Store instructions to the original function. These would then appear in any subsequent resume functions that are cloned from the original, but not the one being processed. Instead an alloca will be created in the first resume function. After the first call to replaceSwiftErrorOps the SwiftErrorOps list is cleared so no other resume functions will get the alloca. Following this replaceSwiftErrorOps is called again after splitting but that would do nothing (right?). Removing the call within the Cloner::create() doesn't break any lit-tests. Can this be safely removed? I am looking at this because I am working on splitting. As explained in llvm#116285 I want to CloneAndPrune to create resume functions that only include the code they need and not the entire original function. However, this call causes coro-swifterror.ll to fail by: swifterror argument should come from an alloca or parameter ptr poison tail call void @maybeThrow(ptr swifterror poison) The swifterror argument is not correctly used in a few places in the IR and some how removing the replaceSwiftErrorOps call in Cloner::create() resolves the problem.
1 parent 6aa7403 commit 13cca95

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

llvm/lib/Transforms/Coroutines/CoroSplit.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ class CoroCloner {
190190
void replaceRetconOrAsyncSuspendUses();
191191
void replaceCoroSuspends();
192192
void replaceCoroEnds();
193-
void replaceSwiftErrorOps();
194193
void salvageDebugInfo();
195194
void handleFinalSuspend();
196195
};
@@ -750,10 +749,6 @@ collectDbgVariableIntrinsics(Function &F) {
750749
return {Intrinsics, DbgVariableRecords};
751750
}
752751

753-
void CoroCloner::replaceSwiftErrorOps() {
754-
::replaceSwiftErrorOps(*NewF, Shape, &VMap);
755-
}
756-
757752
void CoroCloner::salvageDebugInfo() {
758753
auto [Worklist, DbgVariableRecords] = collectDbgVariableIntrinsics(*NewF);
759754
SmallDenseMap<Argument *, AllocaInst *, 4> ArgToAllocaMap;
@@ -1204,9 +1199,6 @@ void CoroCloner::create() {
12041199
// Handle suspends.
12051200
replaceCoroSuspends();
12061201

1207-
// Handle swifterror.
1208-
replaceSwiftErrorOps();
1209-
12101202
// Remove coro.end intrinsics.
12111203
replaceCoroEnds();
12121204

0 commit comments

Comments
 (0)