-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[GlobalOpt] Don't replace aliasee with alias that has weak linkage #91483
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 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
937ab67
Pre-commit test cases
dianqk ab7be41
[GlobalOpt] Don't replace aliasee with alias that has weak linkage
dianqk b901a98
[GlobalOpt] Replace aliasee if it is not in use
dianqk b4660c7
Revert "[GlobalOpt] Replace aliasee if it is not in use"
dianqk 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,56 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --include-generated-funcs --version 4 | ||
; RUN: opt < %s -passes=globalopt -S | FileCheck %s | ||
|
||
@f1_alias = linkonce_odr hidden alias void (), ptr @f1 | ||
@f2_alias = linkonce_odr hidden alias void (), ptr @f2 | ||
|
||
define void @foo() { | ||
call void @f1_alias() | ||
ret void | ||
} | ||
|
||
define void @bar() { | ||
call void @f1() | ||
ret void | ||
} | ||
|
||
define void @baz() { | ||
call void @f2_alias() | ||
ret void | ||
} | ||
|
||
; We cannot use `f1_alias` to replace `f1` because they are both in use | ||
; and `f1_alias` could be replaced at link time. | ||
define internal void @f1() { | ||
ret void | ||
} | ||
|
||
; We can use `f2_alias` to replace `f2` because `b2` is not in use. | ||
define internal void @f2() { | ||
ret void | ||
} | ||
;. | ||
; CHECK: @f1_alias = linkonce_odr hidden alias void (), ptr @f1 | ||
;. | ||
; CHECK-LABEL: define void @foo() local_unnamed_addr { | ||
; CHECK-NEXT: call void @f1_alias() | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: define void @bar() local_unnamed_addr { | ||
; CHECK-NEXT: call void @f1() | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: define void @baz() local_unnamed_addr { | ||
; CHECK-NEXT: call void @f2_alias() | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: define internal void @f1() { | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: define linkonce_odr hidden void @f2_alias() local_unnamed_addr { | ||
; CHECK-NEXT: ret void | ||
; |
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
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.
Since there's a stripPointerCasts() earlier, do we need to check for other uses of a cast ConstantExpr, in addition to other uses of the global itself?
Or maybe we can just drop the whole pointer-cast-stripping thing... with opaque pointer types, not sure if there's any legitimate cast that can show up here. (An addressspacecast would be allowed by the verifier, but not sure it's something we can actually generate code for.)