ipa-icf: Step to the next caller past a thunk in redirect_all_callers
PATCH 1/1 ipa-icf: Step to the next caller past a thunk in redirect_all_callers
redirect_all_callers walks the callers of N, but steps past a thunk caller with next_callee, the next call the thunk makes. A thunk makes only that one call, so the walk ends there, and so the callers after the thunk in the list would not be redirected. This came with the thunk check in commit 17d1bf760f8 ("re PR target/65263").
gcc/ChangeLog:
* ipa-icf.cc (redirect_all_callers): Step to the next caller, not the next callee, past a thunk.
---
I found this while looking through ICF code and Richard's recently proposed changes with inlining, so it's technically unrelated, but it looked wrong. But I haven't found a way to reach it: on targets with symbol aliases a thunk calls a local alias of its function (.LTHUNKn), whose other callers come from redirections and so are ahead of the thunk in the list, and on targets without them, such as Darwin, thunks are expanded to GIMPLE before ICF. So I have not been able to build a test case for this, and I suspect it may just be accidentally/effectively dead code? But the intent of the function didn't seem to match the result of the "else"'s list-walk.
--- gcc/ipa-icf.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
gcc/ipa-icf.cc +1 -1
@@ -995,7 +995,7 @@ redirect_all_callers (cgraph_node *n, cgraph_node *to) nredirected++; } else - e = e->next_callee; + e = e->next_caller; } for (unsigned i = 0; n->iterate_direct_aliases (i, ref);) {
Signature · 1 line
2.55.0
Quoted 5 lines · Kees Cook
redirect_all_callerswalks the callers of N, but steps past a thunk caller withnext_callee, the next call the thunk makes. A thunk makes only that one call, so the walk ends there, and so the callers after the thunk in the list would not be redirected. This came with the thunk check in commit17d1bf760f8("re PR target/65263").
Huh. This looks obvious to me, thus OK unless Jan or Martin object soon.
Thanks,
Richard.
Quoted 35 lines
gcc/ChangeLog:
* ipa-icf.cc (
redirect_all_callers): Step to the next caller, not the next callee, past a thunk.Signed-off-by Kees Cook <[email protected]>---
I found this while looking through ICF code and Richard's recently proposed changes with inlining, so it's technically unrelated, but it looked wrong. But I haven't found a way to reach it: on targets with symbol aliases a thunk calls a local alias of its function (.LTHUNKn), whose other callers come from redirections and so are ahead of the thunk in the list, and on targets without them, such as Darwin, thunks are expanded to GIMPLE before ICF. So I have not been able to build a test case for this, and I suspect it may just be accidentally/effectively dead code? But the intent of the function didn't seem to match the result of the "else"'s list-walk.--- gcc/ipa-icf.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)gcc/ipa-icf.cc +1
-1@@ -995,7 +995,7 @@ redirect_all_callers (cgraph_node *n, cgraph_node *to) nredirected++; } else - e = e->next_callee; + e = e->next_caller; } for (unsigned i = 0; n->iterate_direct_aliases (i, ref);) {
Signature · 4 lines
Richard Biener <[email protected]> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg)
Hi,
Quoted 10 lines · Richard Biener
Quoted 5 lines · Kees Cook
redirect_all_callerswalks the callers of N, but steps past a thunk caller withnext_callee, the next call the thunk makes. A thunk makes only that one call, so the walk ends there, and so the callers after the thunk in the list would not be redirected. This came with the thunk check in commit17d1bf760f8("re PR target/65263").Huh. This looks obvious to me, thus OK unless Jan or Martin object soon.
This is fairly obviously OK.
Thanks for catching this!
Martin
Quoted 45 lines
Thanks,
Richard.Quoted 35 lines
gcc/ChangeLog:
* ipa-icf.cc (
redirect_all_callers): Step to the next caller, not the next callee, past a thunk.Signed-off-by Kees Cook <[email protected]>---
I found this while looking through ICF code and Richard's recently proposed changes with inlining, so it's technically unrelated, but it looked wrong. But I haven't found a way to reach it: on targets with symbol aliases a thunk calls a local alias of its function (.LTHUNKn), whose other callers come from redirections and so are ahead of the thunk in the list, and on targets without them, such as Darwin, thunks are expanded to GIMPLE before ICF. So I have not been able to build a test case for this, and I suspect it may just be accidentally/effectively dead code? But the intent of the function didn't seem to match the result of the "else"'s list-walk.--- gcc/ipa-icf.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)gcc/ipa-icf.cc +1
-1@@ -995,7 +995,7 @@ redirect_all_callers (cgraph_node *n, cgraph_node *to) nredirected++; } else - e = e->next_callee; + e = e->next_caller; } for (unsigned i = 0; n->iterate_direct_aliases (i, ref);) {Signature · 4 lines
Richard Biener <[email protected]> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg)
Quoted 11 lines · Martin Jambor
Hi,
Quoted 8 lines · Richard Biener
Quoted 5 lines · Kees Cook
redirect_all_callerswalks the callers of N, but steps past a thunk caller withnext_callee, the next call the thunk makes. A thunk makes only that one call, so the walk ends there, and so the callers after the thunk in the list would not be redirected. This came with the thunk check in commit17d1bf760f8("re PR target/65263").
Quoted 6 lines
Quoted 2 lines
Huh. This looks obvious to me, thus OK unless Jan or Martin object soon.
This is fairly obviously OK.
Thanks for catching this!
I don't have commit access, so if someone can do that bit for me, I'd appreciate it. :)
Thanks!
Signature · 1 line
Kees Cook
Quoted 16 lines · Kees Cook
Quoted 14 lines · Martin Jambor
Hi,
Quoted 10 lines · Richard Biener
Quoted 5 lines · Kees Cook
redirect_all_callerswalks the callers of N, but steps past a thunk caller withnext_callee, the next call the thunk makes. A thunk makes only that one call, so the walk ends there, and so the callers after the thunk in the list would not be redirected. This came with the thunk check in commit17d1bf760f8("re PR target/65263").Huh. This looks obvious to me, thus OK unless Jan or Martin object soon.
Quoted 6 lines
Quoted 3 lines
This is fairly obviously OK.
Thanks for catching this!
I don't have commit access, so if someone can do that bit for me, I'd appreciate it. :)
Done.
Richard.
Quoted 4 lines
Thanks!
--
Kees Cook