[PATCH] D108122: FunctionAttrs: do not mark coroutines with odd return path `noreturn`
Tim Northover via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 22 01:18:33 PDT 2021
t.p.northover updated this revision to Diff 381477.
t.p.northover added a comment.
Thanks for your thoughts too John, I've implemented your suggestion instead of the `ret undef` path I was thinking about.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108122/new/
https://reviews.llvm.org/D108122
Files:
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
llvm/test/Transforms/Coroutines/coro-retcon.ll
llvm/test/Transforms/FunctionAttrs/noreturn.ll
Index: llvm/test/Transforms/FunctionAttrs/noreturn.ll
===================================================================
--- llvm/test/Transforms/FunctionAttrs/noreturn.ll
+++ llvm/test/Transforms/FunctionAttrs/noreturn.ll
@@ -71,3 +71,20 @@
call i32 @f() noreturn
ret void
}
+
+; CHECK: Function Attrs: {{.*}}noreturn
+; CHECK-NEXT: @unreachable
+define void @unreachable() {
+ unreachable
+}
+
+; CHECK-NOT: Function Attrs: {{.*}}noreturn
+; CHECK: @coro
+define void @coro() "coroutine.presplit"="1" {
+ call token @llvm.coro.id.retcon.once(i32 0, i32 0, i8* null, i8* bitcast(void() *@coro to i8*), i8* null, i8* null)
+ call i1 @llvm.coro.end(i8* null, i1 false)
+ unreachable
+}
+
+declare token @llvm.coro.id.retcon.once(i32 %size, i32 %align, i8* %buffer, i8* %prototype, i8* %alloc, i8* %free)
+declare i1 @llvm.coro.end(i8*, i1)
\ No newline at end of file
Index: llvm/test/Transforms/Coroutines/coro-retcon.ll
===================================================================
--- llvm/test/Transforms/Coroutines/coro-retcon.ll
+++ llvm/test/Transforms/Coroutines/coro-retcon.ll
@@ -72,7 +72,7 @@
define hidden { i8*, i8* } @g(i8* %buffer, i16* %ptr) {
; CHECK-LABEL: @g(
; CHECK-NEXT: coro.return:
-; CHECK-NEXT: [[TMP0:%.*]] = tail call i8* @allocate(i32 8) #[[ATTR0:[0-9]+]]
+; CHECK-NEXT: [[TMP0:%.*]] = tail call i8* @allocate(i32 8)
; CHECK-NEXT: [[TMP1:%.*]] = bitcast i8* [[BUFFER:%.*]] to i8**
; CHECK-NEXT: store i8* [[TMP0]], i8** [[TMP1]], align 8
; CHECK-NEXT: [[PTR_SPILL_ADDR:%.*]] = bitcast i8* [[TMP0]] to i16**
Index: llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
===================================================================
--- llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
+++ llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
@@ -10,7 +10,7 @@
; CHECK-NEXT: [[N_VAL_SPILL_ADDR:%.*]] = getelementptr inbounds i8, i8* [[BUFFER:%.*]], i64 8
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i8* [[N_VAL_SPILL_ADDR]] to i32*
; CHECK-NEXT: store i32 [[N:%.*]], i32* [[TMP0]], align 4
-; CHECK-NEXT: [[TMP1:%.*]] = tail call i8* @allocate(i32 [[N]]) #[[ATTR0:[0-9]+]]
+; CHECK-NEXT: [[TMP1:%.*]] = tail call i8* @allocate(i32 [[N]])
; CHECK-NEXT: [[DOTSPILL_ADDR:%.*]] = bitcast i8* [[BUFFER]] to i8**
; CHECK-NEXT: store i8* [[TMP1]], i8** [[DOTSPILL_ADDR]], align 8
; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { i8*, i8*, i32 } { i8* bitcast ({ i8*, i8*, i32 } (i8*, i1)* @f.resume.0 to i8*), i8* undef, i32 undef }, i8* [[TMP1]], 1
Index: llvm/lib/Transforms/IPO/FunctionAttrs.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -1752,7 +1752,8 @@
SCCNodesResult Res;
Res.HasUnknownCall = false;
for (Function *F : Functions) {
- if (!F || F->hasOptNone() || F->hasFnAttribute(Attribute::Naked)) {
+ if (!F || F->hasOptNone() || F->hasFnAttribute(Attribute::Naked) ||
+ F->isPresplitCoroutine()) {
// Treat any function we're trying not to optimize as if it were an
// indirect call and omit it from the node set used below.
Res.HasUnknownCall = true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108122.381477.patch
Type: text/x-patch
Size: 3215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211022/26bf013e/attachment.bin>
More information about the llvm-commits
mailing list