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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That said, I can't reproduce it on x86_64-linux.

unsigned long long
foo (int x)
{
  switch (x)
    {
    case 0: return 0x123456789abcdefULL;
    case 1: return 0x23456789abcdef0ULL;
    case 2: return 0x3456789abcdef01ULL;
    case 3: return 0x456789a0bcdef01ULL;
    case 4: return 0x56234789abcdefULL;
    case 5: return 0x61234789abcdef0ULL;
    case 6: return 0x8123459abcdef01ULL;
    }
  return 42ULL;
}

unsigned long long
bar (int x)
{
  switch (x)
    {
    case 0: return 0x123456789abcdefULL;
    case 1: return 0x23456789abcdef0ULL;
    case 2: return 0x3456789abcdef01ULL;
    case 3: return 0x456789a0bcdef01ULL;
    case 4: return 0x56234789abcdefULL;
    case 5: return 0x61234789abcdef0ULL;
    case 6: return 0x8123459abcdef01ULL;
    case 7: return 0x8123459abcdef02ULL;
    }
  return 42ULL;
}

unsigned long long
baz (int x)
{
  switch (x)
    {
    case 0: return 0x123456789abcdefULL;
    case 1: return 0x23456789abcdef0ULL;
    case 2: return 0x3456789abcdef01ULL;
    case 3: return 0x456789a0bcdef01ULL;
    }
  return 42ULL;
}

unsigned long long
qux (int x)
{
  switch (x)
    {
    case 0: return 0x123456789abcdefULL;
    case 1: return 0x23456789abcdef0ULL;
    case 2: return 0x3456789abcdef01ULL;
    }
  return 42ULL;
}

This emits only the 24 (uselessly padded to 32) and 32 bytes CSWTCH into
mergeable sections, not the 56 and 64.
That said, there is no reason why it needs to be aligned to 32 bytes, if it is
aligned to e.g. 8 bytes as really needed,
all we need is take that into account in the section name (so that only
sections with the right alignment are merged together).
I think for SHF_MERGE | SHF_STRINGS the section names we use take into account
both entsize and alignment.

Reply via email to