aarch64: Fix an ICE in register_tuple_type [PR95523]
authorz00219097 <z.zhanghaijian@huawei.com>
Wed, 10 Jun 2020 15:58:51 +0000 (16:58 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Wed, 10 Jun 2020 15:58:51 +0000 (16:58 +0100)
When registering the tuple type in register_tuple_type, the
TYPE_ALIGN (tuple_type) will be changed by -fpack-struct=n. We need to
maintain natural alignment in handle_arm_sve_h.

2020-06-10  Haijian Zhang  <z.zhanghaijian@huawei.com>

gcc/
PR target/95523
* config/aarch64/aarch64-sve-builtins.h
(sve_switcher::m_old_maximum_field_alignment): New member.
* config/aarch64/aarch64-sve-builtins.cc
(sve_switcher::sve_switcher): Save maximum_field_alignment in
m_old_maximum_field_alignment and clear maximum_field_alignment.
(sve_switcher::~sve_switcher): Restore maximum_field_alignment.

gcc/testsuite/
PR target/95523
* gcc.target/aarch64/sve/pr95523.c: New test.

gcc/config/aarch64/aarch64-sve-builtins.cc
gcc/config/aarch64/aarch64-sve-builtins.h
gcc/testsuite/gcc.target/aarch64/sve/pr95523.c [new file with mode: 0644]

index bdb04e8170d645bf2deac1e9268eb179ef58ad70..c49fcebcd436dbd8183971ceffa81fb94d2cf760 100644 (file)
@@ -878,6 +878,9 @@ sve_switcher::sve_switcher ()
   aarch64_isa_flags = (AARCH64_FL_FP | AARCH64_FL_SIMD | AARCH64_FL_F16
                       | AARCH64_FL_SVE);
 
+  m_old_maximum_field_alignment = maximum_field_alignment;
+  maximum_field_alignment = 0;
+
   m_old_general_regs_only = TARGET_GENERAL_REGS_ONLY;
   global_options.x_target_flags &= ~MASK_GENERAL_REGS_ONLY;
 
@@ -895,6 +898,7 @@ sve_switcher::~sve_switcher ()
   if (m_old_general_regs_only)
     global_options.x_target_flags |= MASK_GENERAL_REGS_ONLY;
   aarch64_isa_flags = m_old_isa_flags;
+  maximum_field_alignment = m_old_maximum_field_alignment;
 }
 
 function_builder::function_builder ()
index 526d9f55e7bef1b72f106b8c3d597bdac0cf50ab..3ffe2516df9f0bc1c517a998da10f66e0a70c36f 100644 (file)
@@ -658,6 +658,7 @@ public:
 
 private:
   unsigned long m_old_isa_flags;
+  unsigned int m_old_maximum_field_alignment;
   bool m_old_general_regs_only;
   bool m_old_have_regs_of_mode[MAX_MACHINE_MODE];
 };
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr95523.c b/gcc/testsuite/gcc.target/aarch64/sve/pr95523.c
new file mode 100644 (file)
index 0000000..547120a
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fpack-struct=2" } */
+
+#include <arm_sve.h>
+
+void foo ()
+{
+  // Do nothing
+}
+