-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SjLjEHPrepare] Configure call sites correctly #117656
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
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,40 @@ | ||
| ; RUN: opt -p sjlj-eh-prepare %s -S -o - | FileCheck %s | ||
|
|
||
| ; Check that callsites are set up correctly: | ||
| ; 1. Throwing call in the entry block does not set call_site | ||
| ; (function context hasn't been configured yet). | ||
| ; 2. Throwing call not in the entry block sets call_site to -1 | ||
| ; (reset to the initial state). | ||
| ; 3. Invoke instructions set call_site to the correct call site number. | ||
| ; 4. Resume instruction sets call_site to -1 (reset to the initial state). | ||
|
|
||
| define void @test_call_sites() personality ptr @__gxx_personality_sj0 { | ||
| entry: | ||
| ; CHECK-NOT: store volatile | ||
| ; CHECK: call void @may_throw() | ||
| call void @may_throw() | ||
|
|
||
| ; CHECK: store volatile i32 1 | ||
| ; CHECK-NEXT: call void @llvm.eh.sjlj.callsite(i32 1) | ||
| ; CHECK-NEXT: invoke void @may_throw() | ||
| invoke void @may_throw() to label %invoke.cont unwind label %lpad | ||
|
|
||
| invoke.cont: | ||
| ; CHECK: store volatile i32 2 | ||
| ; CHECK-NEXT: call void @llvm.eh.sjlj.callsite(i32 2) | ||
| ; CHECK-NEXT: invoke void @may_throw() | ||
| invoke void @may_throw() to label %try.cont unwind label %lpad | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IR before this change: invoke.cont: ; preds = %entry
%call_site2 = getelementptr { ptr, i32, [4 x i32], ptr, ptr, [5 x ptr] }, ptr %fn_context, i32 0, i32 1
store volatile i32 2, ptr %call_site2, align 4
call void @llvm.eh.sjlj.callsite(i32 2)
%call_site3 = getelementptr { ptr, i32, [4 x i32], ptr, ptr, [5 x ptr] }, ptr %fn_context, i32 0, i32 1
store volatile i32 -1, ptr %call_site3, align 4
invoke void @may_throw()
to label %try.cont unwind label %lpad |
||
|
|
||
| lpad: | ||
| ; CHECK: store volatile i32 -1 | ||
| ; CHECK-NEXT: resume | ||
| %lp = landingpad { ptr, i32 } cleanup | ||
| resume { ptr, i32 } %lp | ||
|
|
||
| try.cont: | ||
| call void @may_throw() | ||
| ret void | ||
| } | ||
|
|
||
| declare void @may_throw() | ||
| declare i32 @__gxx_personality_sj0(...) | ||
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
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.
This NFC change wasn't strictly necessary, but with it the generated code becomes more logical/structured (setting up call sites right before associated calls).