-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[FuncAttrs] Relax norecurse attribute inference #139943
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
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d148825
[FuncAttrs] Relax norecurse attribute when callee is self-recursive
usha1830 41c6eaa
Skip checks on callee which already have norecurse attribute
usha1830 b51fa88
Bail without adding norecurse if address of function is taken as it c…
usha1830 d4f1637
Infer norecurse for functions with external function call/library fun…
usha1830 8d1a31c
Allow norecurse on functions calling library functions only when ther…
usha1830 0a422d9
Check for functions's LocalLinkage when applying norecurse attribute
usha1830 53d477b
Apply optimizations based on linkage and function address only during…
usha1830 6e0bbc2
Revert changes in unaffected tests
usha1830 74225b6
Additional test with a call to library function without NoCallback
usha1830 4e952ed
Added test option to avoid using full lto pipeline, updated tests acc…
usha1830 338a47e
Rename testfiles as per comments
usha1830 1a626a6
Rebased and addressed review comments
usha1830 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
34 changes: 34 additions & 0 deletions
34
llvm/test/Transforms/FunctionAttrs/norecurse_libfunc_address_taken.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,34 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes --version 5 | ||
; RUN: opt < %s -passes=function-attrs -force-lto-funcattrs -S | FileCheck %s | ||
|
||
; This test includes a call to a library function which is not marked as | ||
; NoCallback. Function bob() does not have internal linkage and hence prevents | ||
; norecurse to be added. | ||
|
||
@.str = private unnamed_addr constant [12 x i8] c"Hello World\00", align 1 | ||
|
||
define dso_local void @bob() { | ||
; CHECK-LABEL: define dso_local void @bob() { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[CALL:%.*]] = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str) | ||
; CHECK-NEXT: ret void | ||
; | ||
entry: | ||
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str) | ||
ret void | ||
} | ||
|
||
declare noundef i32 @printf(ptr noundef readonly captures(none), ...) | ||
|
||
define dso_local noundef i32 @main() norecurse { | ||
; CHECK: Function Attrs: norecurse | ||
; CHECK-LABEL: define dso_local noundef i32 @main( | ||
; CHECK-SAME: ) #[[ATTR0:[0-9]+]] { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: tail call void @bob() | ||
; CHECK-NEXT: ret i32 0 | ||
; | ||
entry: | ||
tail call void @bob() | ||
ret i32 0 | ||
} |
39 changes: 39 additions & 0 deletions
39
llvm/test/Transforms/FunctionAttrs/norecurse_libfunc_no_address_taken.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,39 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes --version 5 | ||
; RUN: opt < %s -passes=function-attrs -force-lto-funcattrs -S | FileCheck %s | ||
|
||
; This test includes a call to a library function which is not marked as | ||
; NoCallback. All functions except main() are internal and main is marked | ||
; norecurse, so as to not block norecurse to be added to bob(). | ||
|
||
@.str = private unnamed_addr constant [12 x i8] c"Hello World\00", align 1 | ||
|
||
; Function Attrs: nofree noinline nounwind uwtable | ||
define internal void @bob() { | ||
; CHECK: Function Attrs: norecurse | ||
; CHECK-LABEL: define internal void @bob( | ||
; CHECK-SAME: ) #[[ATTR0:[0-9]+]] { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[CALL:%.*]] = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str) | ||
; CHECK-NEXT: ret void | ||
; | ||
entry: | ||
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str) | ||
ret void | ||
} | ||
|
||
; Function Attrs: nofree nounwind | ||
declare noundef i32 @printf(ptr noundef readonly captures(none), ...) | ||
|
||
; Function Attrs: nofree norecurse nounwind uwtable | ||
define dso_local noundef i32 @main() norecurse { | ||
; CHECK: Function Attrs: norecurse | ||
; CHECK-LABEL: define dso_local noundef i32 @main( | ||
; CHECK-SAME: ) #[[ATTR0]] { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: tail call void @bob() | ||
; CHECK-NEXT: ret i32 0 | ||
; | ||
entry: | ||
tail call void @bob() | ||
ret i32 0 | ||
} |
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.