[PATCH] D110191: [cora async] Cleanup undefined llvm.coro.async.resume
Arnold Schwaighofer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 21 12:17:00 PDT 2021
aschwaighofer created this revision.
aschwaighofer added a reviewer: nate_chandler.
Herald added subscribers: lxfind, hiraditya.
aschwaighofer requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
In situations where the coroutine function is not split we can just
replace the async.resume by null.
rdar://82591919
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110191
Files:
llvm/lib/Transforms/Coroutines/CoroCleanup.cpp
llvm/lib/Transforms/Coroutines/Coroutines.cpp
llvm/test/Transforms/Coroutines/coro-async.ll
Index: llvm/test/Transforms/Coroutines/coro-async.ll
===================================================================
--- llvm/test/Transforms/Coroutines/coro-async.ll
+++ llvm/test/Transforms/Coroutines/coro-async.ll
@@ -534,7 +534,29 @@
call i1 (i8*, i1, ...) @llvm.coro.end.async(i8* %hdl, i1 0)
unreachable
}
+ at undefined_coro_async_resume_fp = constant <{ i32, i32 }>
+ <{ i32 trunc (
+ i64 sub (
+ i64 ptrtoint (void (i8*)* @undefined_coro_async_resume to i64),
+ i64 ptrtoint (i32* getelementptr inbounds (<{ i32, i32 }>, <{ i32, i32 }>* @undefined_coro_async_resume_fp, i32 0, i32 1) to i64)
+ )
+ to i32),
+ i32 24
+}>
+declare void @crash()
+declare void @use(i8*)
+
+define swiftcc void @undefined_coro_async_resume(i8 *%async.ctx) {
+entry:
+ %id = call token @llvm.coro.id.async(i32 24, i32 16, i32 0, i8* bitcast (<{i32, i32}>* @undefined_coro_async_resume_fp to i8*))
+ %hdl = call i8* @llvm.coro.begin(token %id, i8* null)
+ %undefined_resume_pointer = call i8* @llvm.coro.async.resume()
+ call void @use(i8* %undefined_resume_pointer)
+ call void @crash()
+ %unused = call i1 (i8*, i1, ...) @llvm.coro.end.async(i8* %hdl, i1 false)
+ unreachable
+}
; CHECK-LABEL: define swiftcc void @no_coro_suspend_swifterror
; CHECK: [[ALLOCA:%.*]] = alloca swifterror i64*
; CHECK: store i64* null, i64** [[ALLOCA]]
Index: llvm/lib/Transforms/Coroutines/Coroutines.cpp
===================================================================
--- llvm/lib/Transforms/Coroutines/Coroutines.cpp
+++ llvm/lib/Transforms/Coroutines/Coroutines.cpp
@@ -126,6 +126,7 @@
"llvm.coro.alloc",
"llvm.coro.async.context.alloc",
"llvm.coro.async.context.dealloc",
+ "llvm.coro.async.resume",
"llvm.coro.async.size.replace",
"llvm.coro.async.store_resume",
"llvm.coro.begin",
Index: llvm/lib/Transforms/Coroutines/CoroCleanup.cpp
===================================================================
--- llvm/lib/Transforms/Coroutines/CoroCleanup.cpp
+++ llvm/lib/Transforms/Coroutines/CoroCleanup.cpp
@@ -70,6 +70,10 @@
case Intrinsic::coro_alloc:
II->replaceAllUsesWith(ConstantInt::getTrue(Context));
break;
+ case Intrinsic::coro_async_resume:
+ II->replaceAllUsesWith(
+ ConstantPointerNull::get(cast<PointerType>(I.getType())));
+ break;
case Intrinsic::coro_id:
case Intrinsic::coro_id_retcon:
case Intrinsic::coro_id_retcon_once:
@@ -114,7 +118,8 @@
return coro::declaresIntrinsics(
M, {"llvm.coro.alloc", "llvm.coro.begin", "llvm.coro.subfn.addr",
"llvm.coro.free", "llvm.coro.id", "llvm.coro.id.retcon",
- "llvm.coro.id.retcon.once", "llvm.coro.async.size.replace"});
+ "llvm.coro.id.retcon.once", "llvm.coro.async.size.replace",
+ "llvm.coro.async.resume"});
}
PreservedAnalyses CoroCleanupPass::run(Function &F,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110191.374004.patch
Type: text/x-patch
Size: 2945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210921/84d7734d/attachment.bin>
More information about the llvm-commits
mailing list