diff options
author | Alan Modra <amodra@gmail.com> | 2016-03-03 00:35:21 +1030 |
---|---|---|
committer | Alan Modra <amodra@gcc.gnu.org> | 2016-03-03 00:35:21 +1030 |
commit | 90a7a40b65d1057bff07961dd9c8b0c05c345ba8 (patch) | |
tree | 215bc42509d8654673447e88532ee1fb0a10bcf3 /gcc/ipa-icf.c | |
parent | de752fb0d2d3e27407ea5735604577d5aa76bcac (diff) |
decl alignment not respected
This patch cures a problem with ICF of read-only variables at the
intersection of -fsection-anchors, -ftree-loop-vectorize, and targets
with alignment restrictions.
What happens with the testcase is:
- "c" is referenced in a constructor, thus make_decl_rtl for "c",
- make_decl_rtl puts "c" in an anchor block (-fsection-anchors),
- anchor block contents can't move, so "c" alignment can't change by
ipa_increase_alignment (-ftree-loop-vectorize),
- however "a" alignment can be increased,
- ICF aliases "a" to "c".
So we have a decl for "a" saying it is aligned to 128 bits, using mem
for "c" which is only 16 bit aligned.
PR ipa/69990
gcc/
* ipa-icf.c (sem_variable::merge): Do not merge an alias with
larger alignment.
gcc/testsuite/
gcc.dg/pr69990.c: New.
From-SVN: r233906
Diffstat (limited to 'gcc/ipa-icf.c')
-rw-r--r-- | gcc/ipa-icf.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index ef04c559bf4..d82eb879d05 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -2209,6 +2209,16 @@ sem_variable::merge (sem_item *alias_item) "adress of original and alias may be compared.\n\n"); return false; } + + if (DECL_ALIGN (original->decl) < DECL_ALIGN (alias->decl)) + { + if (dump_file) + fprintf (dump_file, "Not unifying; " + "original and alias have incompatible alignments\n\n"); + + return false; + } + if (DECL_COMDAT_GROUP (original->decl) != DECL_COMDAT_GROUP (alias->decl)) { if (dump_file) |