[Bug target/59695] New: bad code generation on aarch64 in aarch64_output_mi_thunk

doko at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jan 6 09:51:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59695

            Bug ID: 59695
           Summary: bad code generation on aarch64 in
                    aarch64_output_mi_thunk
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: doko at gcc dot gnu.org

seen in a segfault running the tests in the coinor-osi package,
https://launchpad.net/bugs/1263576, both in saucy and trusty, version 0.106.4
and 0.106.5. Version 0.103 doesn't show the issue.

both the 4.7 and 4.8 linaro branches show this behaviour, and trunk 20131121
(didn't build a newer one yet).

William Grant tracked that down to a bug with very negative vcall_offsets in
aarch64 multiple inheritance thunks. The example below has two consecutive
thunks, with the second adding 263 instead of subtracting 264.
aarch64_build_constant seems to not handle negative integers. He tried a quick
gcc patch to avoid using aarch64_build_constant, and the coinor-osi tests
succeed.

0000000000401ca4 <_ZTv0_n256_N1C2adEv>:
  401ca4:       f9400010        ldr     x16, [x0]
  401ca8:       f8500211        ldr     x17, [x16,#-256]
  401cac:       8b110000        add     x0, x0, x17
  401cb0:       17fffff9        b       401c94 <_ZN1C2adEv>

[...]

0000000000401cc4 <_ZTv0_n264_N1C2aeEv>:
  401cc4:       f9400010        ldr     x16, [x0]
  401cc8:       d28020f1        mov     x17, #0x107                     // #263
  401ccc:       f8716a11        ldr     x17, [x16,x17]
  401cd0:       8b110000        add     x0, x0, x17
  401cd4:       17fffff8        b       401cb4 <_ZN1C2aeEv>

Any chance for a quick 2013 review?

Thanks, Matthias

--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -2540,8 +2540,8 @@
       addr = plus_constant (Pmode, temp0, vcall_offset);
       else
     {
-      aarch64_build_constant (IP1_REGNUM, vcall_offset);
-      addr = gen_rtx_PLUS (Pmode, temp0, temp1);
+      aarch64_add_constant (IP0_REGNUM, IP1_REGNUM, vcall_offset);
+      addr = temp0;
     }

       aarch64_emit_move (temp1, gen_rtx_MEM (Pmode,addr));



More information about the Gcc-bugs mailing list