-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[BasicBlockUtils] Handle funclets when detaching EH pad blocks #157363
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
efade81
Replace unreachable cleanupret and catchret instruction with unreacha…
spaits 063fccf
Address the case when catchswitch leaves poisoned pads
spaits 0376e58
Clean up and add assertion
spaits 0893d42
Handle catchswitch's unwind
spaits 09b5007
Formating and typo
spaits 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
169 changes: 169 additions & 0 deletions
169
llvm/test/Transforms/SimplifyCFG/unreachable-multi-basic-block-funclet.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,169 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -passes=simplifycfg -S < %s | FileCheck %s | ||
|
||
; cleanuppad/cleanupret | ||
|
||
define void @unreachable_cleanuppad_linear(i64 %shapes.1) personality ptr null { | ||
; CHECK-LABEL: define void @unreachable_cleanuppad_linear( | ||
; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr null { | ||
; CHECK-NEXT: [[START:.*:]] | ||
; CHECK-NEXT: [[_7:%.*]] = icmp ult i64 0, [[SHAPES_1]] | ||
; CHECK-NEXT: ret void | ||
; | ||
start: | ||
%_7 = icmp ult i64 0, %shapes.1 | ||
ret void | ||
|
||
funclet: | ||
%cleanuppad = cleanuppad within none [] | ||
br label %funclet_end | ||
|
||
funclet_end: | ||
cleanupret from %cleanuppad unwind to caller | ||
} | ||
|
||
define void @unreachable_cleanuppad_multiple_predecessors(i64 %shapes.1) personality ptr null { | ||
; CHECK-LABEL: define void @unreachable_cleanuppad_multiple_predecessors( | ||
; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr null { | ||
; CHECK-NEXT: [[START:.*:]] | ||
; CHECK-NEXT: [[_7:%.*]] = icmp ult i64 0, [[SHAPES_1]] | ||
; CHECK-NEXT: ret void | ||
; | ||
start: | ||
%_7 = icmp ult i64 0, %shapes.1 | ||
ret void | ||
|
||
funclet: | ||
%cleanuppad = cleanuppad within none [] | ||
switch i64 %shapes.1, label %otherwise [ i64 0, label %one | ||
i64 1, label %two | ||
i64 42, label %three ] | ||
one: | ||
br label %funclet_end | ||
|
||
two: | ||
br label %funclet_end | ||
|
||
three: | ||
br label %funclet_end | ||
|
||
otherwise: | ||
br label %funclet_end | ||
|
||
funclet_end: | ||
cleanupret from %cleanuppad unwind to caller | ||
} | ||
|
||
; catchpad/catchret | ||
|
||
define void @unreachable_catchpad_linear(i64 %shapes.1) personality ptr null { | ||
; CHECK-LABEL: define void @unreachable_catchpad_linear( | ||
; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr null { | ||
; CHECK-NEXT: [[START:.*:]] | ||
; CHECK-NEXT: [[_7:%.*]] = icmp ult i64 0, [[SHAPES_1]] | ||
; CHECK-NEXT: ret void | ||
; | ||
start: | ||
%_7 = icmp ult i64 0, %shapes.1 | ||
ret void | ||
|
||
dispatch: | ||
%cs = catchswitch within none [label %funclet] unwind to caller | ||
|
||
funclet: | ||
%cleanuppad = catchpad within %cs [] | ||
br label %funclet_end | ||
|
||
|
||
funclet_end: | ||
catchret from %cleanuppad to label %unreachable | ||
|
||
unreachable: | ||
unreachable | ||
} | ||
|
||
define void @unreachable_catchpad_multiple_predecessors(i64 %shapes.1) personality ptr null { | ||
; CHECK-LABEL: define void @unreachable_catchpad_multiple_predecessors( | ||
; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr null { | ||
; CHECK-NEXT: [[START:.*:]] | ||
; CHECK-NEXT: [[_7:%.*]] = icmp ult i64 0, [[SHAPES_1]] | ||
; CHECK-NEXT: ret void | ||
; | ||
start: | ||
%_7 = icmp ult i64 0, %shapes.1 | ||
ret void | ||
|
||
dispatch: | ||
%cs = catchswitch within none [label %funclet] unwind to caller | ||
|
||
funclet: | ||
%cleanuppad = catchpad within %cs [] | ||
switch i64 %shapes.1, label %otherwise [ i64 0, label %one | ||
i64 1, label %two | ||
i64 42, label %three ] | ||
one: | ||
br label %funclet_end | ||
|
||
two: | ||
br label %funclet_end | ||
|
||
three: | ||
br label %funclet_end | ||
|
||
otherwise: | ||
br label %funclet_end | ||
|
||
funclet_end: | ||
catchret from %cleanuppad to label %unreachable | ||
|
||
unreachable: | ||
unreachable | ||
} | ||
|
||
; Issue reproducer | ||
|
||
define void @gh148052(i64 %shapes.1) personality ptr null { | ||
; CHECK-LABEL: define void @gh148052( | ||
; CHECK-SAME: i64 [[SHAPES_1:%.*]]) personality ptr null { | ||
; CHECK-NEXT: [[START:.*:]] | ||
; CHECK-NEXT: [[_7:%.*]] = icmp ult i64 0, [[SHAPES_1]] | ||
; CHECK-NEXT: call void @llvm.assume(i1 [[_7]]) | ||
; CHECK-NEXT: ret void | ||
; | ||
start: | ||
%_7 = icmp ult i64 0, %shapes.1 | ||
br i1 %_7, label %bb1, label %panic | ||
|
||
bb1: | ||
%_11 = icmp ult i64 0, %shapes.1 | ||
br i1 %_11, label %bb3, label %panic1 | ||
|
||
panic: | ||
unreachable | ||
|
||
bb3: | ||
ret void | ||
|
||
panic1: | ||
invoke void @func(i64 0, i64 0, ptr null) | ||
to label %unreachable unwind label %funclet_bb14 | ||
|
||
funclet_bb14: | ||
%cleanuppad = cleanuppad within none [] | ||
br label %bb13 | ||
|
||
unreachable: | ||
unreachable | ||
|
||
bb10: | ||
cleanupret from %cleanuppad5 unwind to caller | ||
|
||
funclet_bb10: | ||
%cleanuppad5 = cleanuppad within none [] | ||
br label %bb10 | ||
|
||
bb13: | ||
cleanupret from %cleanuppad unwind label %funclet_bb10 | ||
} | ||
|
||
declare void @func(i64, i64, ptr) |
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.