-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Coroutines] properly update CallGraph in CoroSplit #107935
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 3 commits into
main
from
users/yuxuanchen1997/fix-coro-split-call-graph-update
Sep 12, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
; Verify that we don't crash on mutually recursive coroutines | ||
; RUN: opt < %s -passes='cgscc(coro-split)' -S | FileCheck %s | ||
|
||
target triple = "x86_64-redhat-linux-gnu" | ||
|
||
; CHECK-LABEL: define void @foo | ||
define void @foo() 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) | ||
%4 = call token @llvm.coro.save(ptr null) | ||
; CHECK: call void @bar(ptr null, ptr null) | ||
call void @llvm.coro.await.suspend.void(ptr null, ptr null, ptr @bar) | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: define void @bar({{.*}}) | ||
define void @bar(ptr %0, ptr %1) { | ||
entry: | ||
; CHECK: call void @foo() | ||
call void @foo() | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @foo.resume({{.*}}) | ||
; CHECK-LABEL: @foo.destroy({{.*}}) | ||
; CHECK-LABEL: @foo.cleanup({{.*}}) | ||
|
||
declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #0 | ||
declare ptr @llvm.coro.begin(token, ptr writeonly) nounwind | ||
declare token @llvm.coro.save(ptr) nomerge nounwind | ||
declare void @llvm.coro.await.suspend.void(ptr, ptr, ptr) | ||
declare i8 @llvm.coro.suspend(token, i1) nounwind | ||
|
||
attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: read) } |
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.
nit: the signature is slightly odd to me. It looks better to make it the below
CurrentSCC
to be an output parameter of the function. So that we can avoid the odd the patternThere 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.
Actually, I can't. It's not just to keep it consistent with the semantics of
updateCGAndAnalysisManagerForCGSCCPass
. TheLazyCallGraph::SCC &C
is an lvalue ref and cannot be rebound. If I doC = update...
it will invoke the Move Assignment operator forLazyCallGraph::SCC
. Not sure the consequence will be intended.My other option is to make this input a
LazyCallGraph::SCC **
orLazyCallGraph::SCC *&
, which is also not very obvious.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't we make the type of
C
toLazyCallGraph::SCC *&
?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.
I noted that the signature is actually very similar to LLVM's updateCGAndAnalysisManagerForPass() signature. Perhaps it is better to be consistent with that? https://llvm.org/doxygen/CGSCCPassManager_8cpp.html#a490117b63072462d035a6933fdb94c1f
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.
Perhaps. Or perhaps the answer is to rewrite
updateCGAndAnalysisManagerForPass
. I really don't like the current semantics. I will see what I can do in another patch.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.
@ChuanqiXu9 I am reverting this suggestion for now. We can do a refactor to change all
updateCGAndAnalysisManagerFor(Function|CGSCC)?Pass
usage once we decide on a new design.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.
This is manageable refactoring I'd say. Let's do this in a separate patch.