-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[llvm][GlobalOpt] Remove empty atexit destructors/handlers #88836
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
14 commits
Select commit
Hold shift + click to select a range
cb1616a
Remove empty atexit destructors
MaxEW707 d5cd155
formatting
MaxEW707 f5e276d
eol
MaxEW707 d38ec0c
unit test for explicit at exit registration
MaxEW707 dfd476b
eol
MaxEW707 a3a8419
formatting
MaxEW707 8bedd9c
fix unit test
MaxEW707 f1b585f
Add atexit to ps tli checker
MaxEW707 08f30d5
fix formatting
MaxEW707 e9b1eb5
Remove static functions; Feedback variable scoping
MaxEW707 00c6aed
autogenerate check statements for unit test
MaxEW707 23ff313
fix formatting
MaxEW707 cedb55f
add negative unit tests
MaxEW707 8abf12a
Rebuild due to windows agent out of heap space error from msvc
MaxEW707 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,54 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 | ||
; RUN: opt < %s -S -passes=globalopt | FileCheck %s | ||
|
||
declare dso_local i32 @atexit(ptr) | ||
|
||
define dso_local void @empty_atexit_handler() { | ||
; CHECK-LABEL: define dso_local void @empty_atexit_handler() local_unnamed_addr { | ||
; CHECK-NEXT: ret void | ||
; | ||
ret void | ||
} | ||
|
||
; Check that `atexit` is removed if the handler is empty. | ||
; Check that a removed `atexit` call returns `0` which is the value that denotes success. | ||
define dso_local noundef i32 @register_atexit_handler() { | ||
; CHECK-LABEL: define dso_local noundef i32 @register_atexit_handler() local_unnamed_addr { | ||
; CHECK-NEXT: ret i32 0 | ||
; | ||
%1 = call i32 @atexit(ptr @empty_atexit_handler) | ||
ret i32 %1 | ||
} | ||
|
||
declare dso_local void @declared_atexit_handler() | ||
|
||
; Check that an atexit handler with only a declaration is not removed. | ||
define dso_local noundef i32 @register_declared_atexit_handler() { | ||
; CHECK-LABEL: define dso_local noundef i32 @register_declared_atexit_handler() local_unnamed_addr { | ||
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @atexit(ptr @declared_atexit_handler) | ||
; CHECK-NEXT: ret i32 [[TMP1]] | ||
; | ||
%1 = call i32 @atexit(ptr @declared_atexit_handler) | ||
ret i32 %1 | ||
} | ||
|
||
declare dso_local void @external_exit_func() | ||
|
||
define dso_local void @nonempty_atexit_handler() { | ||
; CHECK-LABEL: define dso_local void @nonempty_atexit_handler() { | ||
; CHECK-NEXT: call void @external_exit_func() | ||
; CHECK-NEXT: ret void | ||
; | ||
call void @external_exit_func() | ||
ret void | ||
} | ||
|
||
; Check that an atexit handler that consists of any instructions other than `ret` is considered nonempty and not removed. | ||
define dso_local noundef i32 @register_nonempty_atexit_handler() { | ||
; CHECK-LABEL: define dso_local noundef i32 @register_nonempty_atexit_handler() local_unnamed_addr { | ||
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @atexit(ptr @nonempty_atexit_handler) | ||
; CHECK-NEXT: ret i32 [[TMP1]] | ||
; | ||
%1 = call i32 @atexit(ptr @nonempty_atexit_handler) | ||
ret i32 %1 | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
@pogo59 @sks75220 Let me know for ps4/ps5 if you prefer that this library function be set unavailable.
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.
atexit
should be available for PS4/PS5, thanks!