https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89490

--- Comment #5 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
The patch should probably work, and a powerpc cross fixes the test case.
At least bootstrap and reg-test on x86_64-pc-linux-gnu is fine,
but that proves not too much.

When I look at the merge-all-constants-2.c test case, I think
the mergeable string secrtion looks bogus (unrelated to this):

$ cat merge-all-constants-2.c
/* { dg-do compile } */
/* { dg-require-effective-target string_merging } */
/* { dg-options "-w -O2 -fmerge-all-constants" } */

const char str1[36] = "0123456789abcdefghijklmnopqrstuvwxyz";
const char str2[37] = "0123456789abcdefghijklmnopqrstuvwxyz";
const char str3[10] = "0123456789abcdefghijklmnopqrstuvwxyz";

/* { dg-final { scan-assembler-not "\\.rodata\[\n\r\]" } } */
$ powerpc64-unknown-linux-gcc -O2 -S merge-all-constants-2.c
merge-all-constants-2.c:7:23: warning: initializer-string for array of chars is
too long
    7 | const char str3[10] = "0123456789abcdefghijklmnopqrstuvwxyz";
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ cat merge-all-constants-2.s
        .file   "merge-all-constants-2.c"
        .machine power4
        .section        ".text"
        .globl str3
        .globl str2
        .globl str1
        .section        .rodata.str1.8,"aMS",@progbits,1
        .align 3
        .type   str3, @object
        .size   str3, 10
str3:
        .string "0123456789"
        .zero   6
        .type   str2, @object
        .size   str2, 37
str2:
        .string "0123456789abcdefghijklmnopqrstuvwxyz"
        .zero   3
        .type   str1, @object
        .size   str1, 36
str1:
        .string "0123456789abcdefghijklmnopqrstuvwxyz"
        .ident  "GCC: (GNU) 9.0.1 20190222 (experimental)"


Adding zero bytes after each string constant makes no sense IMHO,
since the linker will merge the constants, and so aligning the
constants with .zero does probably not work, but the should be
benign, except for that the alignment of the string constants.

Reply via email to