-
Notifications
You must be signed in to change notification settings - Fork 17.9k
[CoroCleanup] Noop coroutine elision for load-and-call pattern #179154
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
Merged
Changes from 1 commit
Commits
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
51 changes: 51 additions & 0 deletions
51
llvm/test/Transforms/Coroutines/coro-cleanup-noop-elide.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,51 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6 | ||
| ; RUN: opt < %s -S -passes='coro-cleanup' | FileCheck %s | ||
|
|
||
| ; Tests that resume or destroy a no-op coroutine can be erased; Finally, erase coro.noop if it has no users. | ||
| define void @erase() personality i32 0 { | ||
| ; CHECK-LABEL: define void @erase() personality i32 0 { | ||
| ; CHECK-NEXT: [[DONE:.*:]] | ||
| ; CHECK-NEXT: ret void | ||
| ; | ||
| %frame = call noundef ptr @llvm.coro.noop() | ||
| %resume = call ptr @llvm.coro.subfn.addr(ptr %frame, i8 0) | ||
| call fastcc void %resume(ptr %frame) | ||
| %destroy = call ptr @llvm.coro.subfn.addr(ptr %frame, i8 1) | ||
| invoke fastcc void %destroy(ptr %frame) | ||
| to label %done unwind label %unwind | ||
|
|
||
| done: | ||
| ret void | ||
|
|
||
| unwind: | ||
| %pad = landingpad { ptr, i32 } | ||
| catch ptr null | ||
| call void @terminate() | ||
| unreachable | ||
| } | ||
|
|
||
| ; Tests the load-and-call pattern despite mismatched calling conventions. Prevent instcombine from breaking code. | ||
| define void @load() personality i32 0 { | ||
| ; CHECK-LABEL: define void @load() personality i32 0 { | ||
| ; CHECK-NEXT: [[DONE:.*:]] | ||
| ; CHECK-NEXT: ret void | ||
| ; | ||
| %frame = call noundef ptr @llvm.coro.noop() | ||
| %resume = load ptr, ptr %frame, align 8 | ||
| call void %resume(ptr %frame) | ||
| %destroy.addr = getelementptr inbounds nuw i8, ptr %frame, i64 8 | ||
| %destroy = load ptr, ptr %destroy.addr, align 8 | ||
| invoke void %destroy(ptr %frame) | ||
| to label %done unwind label %unwind | ||
|
|
||
| done: | ||
| ret void | ||
|
|
||
| unwind: | ||
| %pad = landingpad { ptr, i32 } | ||
| catch ptr null | ||
| call void @terminate() | ||
| unreachable | ||
| } | ||
|
|
||
| declare void @terminate() noreturn |
24 changes: 0 additions & 24 deletions
24
llvm/test/Transforms/Coroutines/coro-cleanup-noop-erase.ll
This file was deleted.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.