-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[FuncSpec] Skip SCCP on blocks of dead functions and poison their callsites #154668
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
6 commits
Select commit
Hold shift + click to select a range
bc9c37a
[FunctionnSpecializer] Do not mark function dead if any unexecutable …
XChy 1067b5c
format
XChy b207e13
resolve comments
XChy af78e24
Replace the concept FullySpecialized with DeadFunctions and force for…
XChy 1d01fa8
add testcase for address taken
XChy 0e5ab29
add testcase to show poison replacement
XChy 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
135 changes: 135 additions & 0 deletions
135
llvm/test/Transforms/FunctionSpecialization/reachable-after-specialization.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,135 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: opt -passes=ipsccp --funcspec-min-function-size=1 -S < %s | FileCheck %s | ||
|
|
||
| define i32 @caller() { | ||
| ; CHECK-LABEL: define i32 @caller() { | ||
| ; CHECK-NEXT: [[ENTRY:.*:]] | ||
| ; CHECK-NEXT: [[CALL1:%.*]] = call i32 @callee.specialized.1(i32 1) | ||
| ; CHECK-NEXT: [[CALL2:%.*]] = call i32 @callee.specialized.2(i32 0) | ||
| ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 undef, 0 | ||
| ; CHECK-NEXT: br i1 [[COND]], label %[[COMMON_RET:.*]], label %[[IF_THEN:.*]] | ||
| ; CHECK: [[COMMON_RET]]: | ||
| ; CHECK-NEXT: ret i32 0 | ||
| ; CHECK: [[IF_THEN]]: | ||
| ; CHECK-NEXT: ret i32 0 | ||
labrinea marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ; | ||
| entry: | ||
| %call1 = call i32 @callee(i32 1) | ||
| %call2 = call i32 @callee(i32 0) | ||
| %cond = icmp eq i32 %call2, 0 | ||
| br i1 %cond, label %common.ret, label %if.then | ||
|
|
||
| common.ret: ; preds = %entry | ||
| ret i32 0 | ||
|
|
||
| if.then: ; preds = %entry | ||
| %unreachable_call = call i32 @callee(i32 2) | ||
| ret i32 %unreachable_call | ||
| } | ||
|
|
||
| define internal i32 @callee(i32 %arg) { | ||
| entry: | ||
| br label %loop | ||
|
|
||
| loop: ; preds = %ai, %entry | ||
| %add = or i32 0, 0 | ||
| %cond = icmp eq i32 %arg, 1 | ||
| br i1 %cond, label %exit, label %loop | ||
|
|
||
| exit: ; preds = %ai | ||
| ret i32 0 | ||
| } | ||
|
|
||
| declare void @other_user(ptr) | ||
|
|
||
| define i32 @caller2() { | ||
| ; CHECK-LABEL: define i32 @caller2() { | ||
| ; CHECK-NEXT: [[ENTRY:.*:]] | ||
| ; CHECK-NEXT: call void @other_user(ptr @callee2) | ||
| ; CHECK-NEXT: [[CALL1:%.*]] = call i32 @callee2.specialized.3(i32 1) | ||
| ; CHECK-NEXT: [[CALL2:%.*]] = call i32 @callee2.specialized.4(i32 0) | ||
| ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 undef, 0 | ||
| ; CHECK-NEXT: br i1 [[COND]], label %[[COMMON_RET:.*]], label %[[IF_THEN:.*]] | ||
| ; CHECK: [[COMMON_RET]]: | ||
| ; CHECK-NEXT: ret i32 0 | ||
| ; CHECK: [[IF_THEN]]: | ||
| ; CHECK-NEXT: [[UNREACHABLE_CALL:%.*]] = call i32 @callee2.specialized.7(i32 2) | ||
| ; CHECK-NEXT: ret i32 undef | ||
| ; | ||
| entry: | ||
| call void @other_user(ptr @callee2) | ||
| %call1 = call i32 @callee2(i32 1) | ||
| %call2 = call i32 @callee2(i32 0) | ||
| %cond = icmp eq i32 %call2, 0 | ||
| br i1 %cond, label %common.ret, label %if.then | ||
|
|
||
| common.ret: ; preds = %entry | ||
| ret i32 0 | ||
|
|
||
| if.then: ; preds = %entry | ||
| %unreachable_call = call i32 @callee2(i32 2) | ||
| ret i32 %unreachable_call | ||
| } | ||
|
|
||
| define internal i32 @callee2(i32 %arg) { | ||
| ; CHECK-LABEL: define internal i32 @callee2( | ||
| ; CHECK-SAME: i32 [[ARG:%.*]]) { | ||
| ; CHECK-NEXT: [[ENTRY:.*:]] | ||
| ; CHECK-NEXT: br label %[[LOOP:.*]] | ||
| ; CHECK: [[LOOP]]: | ||
| ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[ARG]], 1 | ||
| ; CHECK-NEXT: br i1 [[COND]], label %[[EXIT:.*]], label %[[LOOP]] | ||
| ; CHECK: [[EXIT]]: | ||
| ; CHECK-NEXT: ret i32 0 | ||
| ; | ||
| entry: | ||
| br label %loop | ||
|
|
||
| loop: ; preds = %ai, %entry | ||
| %add = or i32 0, 0 | ||
| %cond = icmp eq i32 %arg, 1 | ||
| br i1 %cond, label %exit, label %loop | ||
|
|
||
| exit: ; preds = %ai | ||
| ret i32 0 | ||
| } | ||
|
|
||
| define i32 @caller3(i32 %arg) { | ||
| ; CHECK-LABEL: define range(i32 2, 1) i32 @caller3( | ||
| ; CHECK-SAME: i32 [[ARG:%.*]]) { | ||
| ; CHECK-NEXT: [[ENTRY:.*:]] | ||
| ; CHECK-NEXT: [[CALL1:%.*]] = call i32 @callee3.specialized.5(i32 0) | ||
| ; CHECK-NEXT: [[CALL2:%.*]] = call i32 @callee3.specialized.6(i32 1) | ||
| ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 undef, 0 | ||
| ; CHECK-NEXT: br i1 [[COND]], label %[[COMMON_RET:.*]], label %[[IF_THEN:.*]] | ||
| ; CHECK: [[COMMON_RET]]: | ||
| ; CHECK-NEXT: ret i32 0 | ||
| ; CHECK: [[IF_THEN]]: | ||
| ; CHECK-NEXT: ret i32 poison | ||
| ; | ||
| entry: | ||
| %call1 = call i32 @callee3(i32 0) | ||
| %call2 = call i32 @callee3(i32 1) | ||
| %cond = icmp eq i32 %call2, 0 | ||
| br i1 %cond, label %common.ret, label %if.then | ||
|
|
||
| common.ret: ; preds = %entry | ||
| ret i32 0 | ||
|
|
||
| if.then: ; preds = %entry | ||
| %unreachable_call = call i32 @callee3(i32 %arg) | ||
| ret i32 %unreachable_call | ||
| } | ||
|
|
||
| define internal i32 @callee3(i32 %arg) { | ||
| entry: | ||
| br label %loop | ||
|
|
||
| loop: ; preds = %ai, %entry | ||
| %add = or i32 0, 0 | ||
| %cond = icmp ne i32 %arg, 1 | ||
| br i1 %cond, label %exit, label %loop | ||
|
|
||
| exit: ; preds = %ai | ||
| ret i32 %arg | ||
| } | ||
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.