aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-09-19 08:14:47 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-09-19 08:14:47 +0000
commitc3a75a09b8424c192b32a39fa273d27db5b9c039 (patch)
tree02248dbe080cb8039d06d8da007945feaac10b45 /gcc/ada
parent87cd385fa5dad3a0e5d144e08670c7fdd85fe2ef (diff)
downloadgcc-c3a75a09b8424c192b32a39fa273d27db5b9c039.zip
gcc-c3a75a09b8424c192b32a39fa273d27db5b9c039.tar.gz
gcc-c3a75a09b8424c192b32a39fa273d27db5b9c039.tar.bz2
[Ada] Get rid of useless temporary for slice in overaligned record type
This fixes a recent code quality regression for targets that do not require the strict alignment of memory accesses: the compiler would generate a useless temporary for a slice of an array component in an overaligned record type. Running these commands: gcc -c p.adb -gnatws -gnatD grep loop p.adb.dg On the following sources: procedure P (N : Positive) is type Rec1 is record I : Integer; end record; type Arr is array (Positive range <>) of Rec1; type Rec2 is record A : Arr (1 .. 128); end record; for Rec2'Alignment use 8; procedure Proc (A : Arr) is begin null; end; R : Rec2; begin Proc (R.A (1 .. N)); end; Should execute silently. 2019-09-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_util.adb (Is_Possibly_Unaligned_Slice): Do not return true on pure alignment considerations if the target does not require the strict alignment of memory accesses. From-SVN: r275956
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/exp_util.adb6
2 files changed, 10 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 8a87274..5808008 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,11 @@
2019-09-19 Eric Botcazou <ebotcazou@adacore.com>
+ * exp_util.adb (Is_Possibly_Unaligned_Slice): Do not return true
+ on pure alignment considerations if the target does not require
+ the strict alignment of memory accesses.
+
+2019-09-19 Eric Botcazou <ebotcazou@adacore.com>
+
* sem_ch12.adb (Check_Private_View): Add a comment to indicate
future work.
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 905e3f4..6306320 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -8692,9 +8692,11 @@ package body Exp_Util is
-- We are definitely in trouble if the record in question
-- has an alignment, and either we know this alignment is
-- inconsistent with the alignment of the slice, or we don't
- -- know what the alignment of the slice should be.
+ -- know what the alignment of the slice should be. But this
+ -- really matters only if the target has strict alignment.
- if Known_Alignment (Ptyp)
+ if Target_Strict_Alignment
+ and then Known_Alignment (Ptyp)
and then (Unknown_Alignment (Styp)
or else Alignment (Styp) > Alignment (Ptyp))
then