-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Coroutines] Inline the .noalloc
ramp function marked coro_safe_elide
#114004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yuxuanchen1997
merged 6 commits into
main
from
users/yuxuanchen1997/coro-fix-cgscc-update
Nov 8, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
61005bf
Revert "[LLVM][Coroutines] Switch CoroAnnotationElidePass to a Functi…
yuxuanchen1997 00b1d1b
inline new call to caller
yuxuanchen1997 62131d5
add test case
yuxuanchen1997 1fea9e0
git clang-format
yuxuanchen1997 28a4c3d
add non-inlineable test case
yuxuanchen1997 2cb9dd7
fix existing test due to inlining
yuxuanchen1997 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
llvm/test/Transforms/Coroutines/gh114487-crash-in-cgscc.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
; Verify that we don't crash when eliding coro_elide_safe callsites. | ||
; RUN: opt < %s -passes='cgscc(function<>(simplifycfg<>),function-attrs,coro-split,coro-annotation-elide)' -S | FileCheck %s | ||
|
||
; CHECK-LABEL: define void @foo() | ||
define void @foo() presplitcoroutine personality ptr null { | ||
entry: | ||
%0 = call token @llvm.coro.save(ptr null) | ||
br label %branch | ||
|
||
branch: | ||
; Check that we don't call bar at all. | ||
; CHECK-NOT: call void @bar{{.*}} | ||
call void @bar() coro_elide_safe | ||
; CHECK: call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @bar.resumers) | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: define void @bar() | ||
define void @bar() presplitcoroutine personality ptr null { | ||
entry: | ||
%0 = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null) | ||
%1 = call ptr @llvm.coro.begin(token %0, ptr null) | ||
%2 = call token @llvm.coro.save(ptr null) | ||
%3 = call i8 @llvm.coro.suspend(token none, i1 false) | ||
ret void | ||
} | ||
|
||
declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) nounwind | ||
declare ptr @llvm.coro.begin(token, ptr writeonly) nounwind | ||
declare token @llvm.coro.save(ptr) nomerge nounwind | ||
declare i8 @llvm.coro.suspend(token, i1) nounwind | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
; Verify that we don't crash when eliding coro_elide_safe callsites. | ||
; RUN: opt < %s -passes='cgscc(function<>(simplifycfg<>),function-attrs,coro-annotation-elide)' -S | FileCheck %s | ||
|
||
; CHECK-LABEL: define void @foo() | ||
define void @foo() presplitcoroutine personality ptr null { | ||
entry: | ||
%0 = call token @llvm.coro.save(ptr null) | ||
br label %branch | ||
|
||
branch: | ||
; Check that we still call bar() because we can't inline bar.noalloc() | ||
; CHECK: call void @bar() | ||
call void @bar() coro_elide_safe | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: define void @bar() | ||
define void @bar() personality ptr null { | ||
entry: | ||
%0 = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null) | ||
%1 = call ptr @llvm.coro.begin(token %0, ptr null) | ||
%2 = call token @llvm.coro.save(ptr null) | ||
%3 = call i8 @llvm.coro.suspend(token none, i1 false) | ||
ret void | ||
} | ||
|
||
declare void @bar.noalloc(ptr) | ||
|
||
declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) nounwind | ||
declare ptr @llvm.coro.begin(token, ptr writeonly) nounwind | ||
declare token @llvm.coro.save(ptr) nomerge nounwind | ||
declare i8 @llvm.coro.suspend(token, i1) nounwind | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test for the failed to inline case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added. Sorry for the delay.