-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[llvm][GlobalOpt] Optimize statically resolvable IFuncs #80606
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
10 commits
Select commit
Hold shift + click to select a range
5318a4d
[llvm][GlobalOpt] Optimize statically resolvable IFuncs
jroelofs 633116c
apply nikic's feedback
jroelofs a62ad24
delete dead ifuncs
jroelofs 940090f
simplify fn names in test
jroelofs c05c28b
don't forget to update Changed
jroelofs 929c23e
use deleteIfDead
jroelofs 6e11201
clang-format
jroelofs 96d584e
clang-format again
jroelofs 53a7b10
fix test copy-pasta
jroelofs 0bf69ed
also skip interposable ifuncs
jroelofs 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,109 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function caller --check-globals all --version 4 | ||
; RUN: opt --passes=globalopt -o - -S < %s | FileCheck %s --implicit-check-not=trivial\.ifunc --implicit-check-not=dead_ifunc | ||
|
||
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" | ||
target triple = "aarch64-unknown-linux-gnu" | ||
|
||
@trivial.ifunc = internal ifunc void (), ptr @trivial.resolver | ||
;. | ||
; CHECK: @unknown_condition = external local_unnamed_addr global i1 | ||
; CHECK: @external_ifunc.ifunc = dso_local ifunc void (), ptr @external_ifunc.resolver | ||
; CHECK: @complex.ifunc = internal ifunc void (), ptr @complex.resolver | ||
; CHECK: @sideeffects.ifunc = internal ifunc void (), ptr @sideeffects.resolver | ||
; CHECK: @interposable_ifunc.ifunc = internal ifunc void (), ptr @interposable_ifunc.resolver | ||
; CHECK: @interposable_resolver.ifunc = weak ifunc void (), ptr @interposable_resolver.resolver | ||
;. | ||
define ptr @trivial.resolver() { | ||
ret ptr @trivial._Msimd | ||
} | ||
define void @trivial._Msimd() { | ||
ret void | ||
} | ||
define void @trivial.default() { | ||
ret void | ||
} | ||
|
||
|
||
@dead_ifunc.ifunc = internal ifunc void (), ptr @trivial.resolver | ||
|
||
@external_ifunc.ifunc = dso_local ifunc void (), ptr @external_ifunc.resolver | ||
define ptr @external_ifunc.resolver() { | ||
ret ptr @external_ifunc._Msimd | ||
} | ||
define void @external_ifunc._Msimd() { | ||
ret void | ||
} | ||
define void @external_ifunc.default() { | ||
ret void | ||
} | ||
|
||
@unknown_condition = external global i1 | ||
@complex.ifunc = internal ifunc void (), ptr @complex.resolver | ||
define ptr @complex.resolver() { | ||
entry: | ||
%v = load i1, ptr @unknown_condition | ||
br i1 %v, label %fast, label %slow | ||
fast: | ||
ret ptr @complex._Msimd | ||
slow: | ||
ret ptr @complex._Msimd | ||
} | ||
define void @complex._Msimd() { | ||
ret void | ||
} | ||
define void @complex.default() { | ||
ret void | ||
} | ||
|
||
@sideeffects.ifunc = internal ifunc void (), ptr @sideeffects.resolver | ||
define ptr @sideeffects.resolver() { | ||
store i1 0, ptr @unknown_condition | ||
ret ptr @sideeffects.default | ||
} | ||
define void @sideeffects._Msimd() { | ||
ret void | ||
} | ||
define void @sideeffects.default() { | ||
ret void | ||
} | ||
|
||
@interposable_ifunc.ifunc = internal ifunc void (), ptr @interposable_ifunc.resolver | ||
define weak ptr @interposable_ifunc.resolver() { | ||
ret ptr @interposable_ifunc.resolver | ||
} | ||
define void @interposable_ifunc._Msimd() { | ||
ret void | ||
} | ||
define void @interposable_ifunc.default() { | ||
ret void | ||
} | ||
|
||
@interposable_resolver.ifunc = weak ifunc void (), ptr @interposable_resolver.resolver | ||
define ptr @interposable_resolver.resolver() { | ||
ret ptr @interposable_resolver.resolver | ||
} | ||
define void @interposable_resolver._Msimd() { | ||
ret void | ||
} | ||
define void @interposable_resolver.default() { | ||
ret void | ||
} | ||
|
||
define void @caller() { | ||
; CHECK-LABEL: define void @caller() local_unnamed_addr { | ||
; CHECK-NEXT: call void @trivial._Msimd() | ||
; CHECK-NEXT: call void @external_ifunc._Msimd() | ||
; CHECK-NEXT: call void @complex.ifunc() | ||
; CHECK-NEXT: call void @sideeffects.ifunc() | ||
; CHECK-NEXT: call void @interposable_ifunc.ifunc() | ||
; CHECK-NEXT: call void @interposable_resolver.ifunc() | ||
; CHECK-NEXT: ret void | ||
; | ||
call void @trivial.ifunc() | ||
call void @external_ifunc.ifunc() | ||
call void @complex.ifunc() | ||
call void @sideeffects.ifunc() | ||
call void @interposable_ifunc.ifunc() | ||
call void @interposable_resolver.ifunc() | ||
ret void | ||
} |
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.