-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ipa: Compare jump functions in ICF (PR 113907)
In PR 113907 comment #58, Honza found a case where ICF thinks bodies of functions are equivalent but becaise of difference in aliases in a memory access, different aggregate jump functions are associated with supposedly equivalent call statements. This patch adds a way to compare jump functions and plugs it into ICF to avoid the issue. gcc/ChangeLog: 2024-03-20 Martin Jambor <[email protected]> PR ipa/113907 * ipa-prop.h (class ipa_vr): Declare new overload of a member function equal_p. (ipa_jump_functions_equivalent_p): Declare. * ipa-prop.cc (ipa_vr::equal_p): New function. (ipa_agg_pass_through_jf_equivalent_p): Likewise. (ipa_agg_jump_functions_equivalent_p): Likewise. (ipa_jump_functions_equivalent_p): Likewise. * ipa-cp.h (values_equal_for_ipcp_p): Declare. * ipa-cp.cc (values_equal_for_ipcp_p): Make function public. * ipa-icf-gimple.cc: Include alloc-pool.h, symbol-summary.h, sreal.h, ipa-cp.h and ipa-prop.h. (func_checker::compare_gimple_call): Comapre jump functions. gcc/testsuite/ChangeLog: 2024-03-20 Martin Jambor <[email protected]> PR ipa/113907 * gcc.dg/lto/pr113907_0.c: New. * gcc.dg/lto/pr113907_1.c: Likewise. * gcc.dg/lto/pr113907_2.c: Likewise.
- Loading branch information
Showing
8 changed files
with
267 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,18 @@ | ||
/* { dg-lto-do run } */ | ||
/* { dg-lto-options {{-O3 -flto}} } */ | ||
|
||
struct bar {int a;}; | ||
struct foo {int a;}; | ||
struct barp {struct bar *f; struct bar *g;}; | ||
extern struct foo **ptr; | ||
int test2 (void *); | ||
int test3 (void *); | ||
int | ||
testb(void) | ||
{ | ||
struct bar *fp; | ||
test2 ((void *)&fp); | ||
fp = (void *) 0; | ||
(*ptr)++; | ||
test3 ((void *)&fp); | ||
} |
This file contains 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,35 @@ | ||
__attribute__((used)) int val,val2 = 1; | ||
|
||
struct foo {int a;}; | ||
|
||
struct foo **ptr; | ||
|
||
__attribute__ ((noipa)) | ||
int | ||
test2 (void *a) | ||
{ | ||
ptr = (struct foo **)a; | ||
} | ||
int test3 (void *a); | ||
|
||
int | ||
test(void) | ||
{ | ||
struct foo *fp; | ||
test2 ((void *)&fp); | ||
fp = (void *) 0; | ||
(*ptr)++; | ||
test3 ((void *)&fp); | ||
} | ||
|
||
int testb (void); | ||
|
||
int | ||
main() | ||
{ | ||
for (int i = 0; i < val2; i++) | ||
if (val) | ||
testb (); | ||
else | ||
test(); | ||
} |
This file contains 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,11 @@ | ||
/* { dg-options "-O3 -flto -fno-strict-aliasing" } */ | ||
|
||
__attribute__ ((noinline)) | ||
int | ||
test3 (void *a) | ||
{ | ||
if (!*(void **)a) | ||
__builtin_abort (); | ||
return 0; | ||
} | ||
|