public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/113723] New: -freorder-blocks-and-partition emits bogus asm directives on aarch64
@ 2024-02-02 15:33 redbeard0531 at gmail dot com
  2024-02-02 15:43 ` [Bug target/113723] " redbeard0531 at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: redbeard0531 at gmail dot com @ 2024-02-02 15:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113723
           Summary: -freorder-blocks-and-partition emits bogus asm
                    directives on aarch64
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redbeard0531 at gmail dot com
  Target Milestone: ---

It tries to subtract labels across the function split which the assembler
rejects. At the very least it does this when generating a switch jump table,
but there may be other cases.

https://www.godbolt.org/z/Ynh1zzY4a

Repro with -O3 -freorder-blocks-and-partition:


[[gnu::cold]]void cold();

template<int i> void f();
#define GENERATE_CASE case __COUNTER__: f<__COUNTER__>(); break 

void test(int i) {
    switch(i) {
        case 1: cold(); break;
        GENERATE_CASE;
        GENERATE_CASE;
        GENERATE_CASE;
        GENERATE_CASE;
        GENERATE_CASE;
        GENERATE_CASE;
        GENERATE_CASE;
        GENERATE_CASE;
        GENERATE_CASE;
        GENERATE_CASE;
    }
}

test(int):
        cmp     w0, 18
        bls     .L17
.L1:
        ret
.L17:
        adrp    x1, .L4
        add     x1, x1, :lo12:.L4
        ldrb    w1, [x1,w0,uxtw]
        adr     x0, .Lrtx4
        add     x1, x0, w1, sxtb #2
        br      x1
.Lrtx4:
.L4:
        .byte   (.L14 - .Lrtx4) / 4
        .byte   (.L13 - .Lrtx4) / 4 // <<<< THIS IS THE BAD ONE
        .byte   (.L12 - .Lrtx4) / 4

...

test(int) [clone .cold]:
.L13:
        b       cold()


/tmp/cck05x4u.s: Assembler messages:
/tmp/cck05x4u.s:48: Error: invalid operands (.text.unlikely and .text sections)
for `-'
Compiler returned: 1

I've repro'd on 11,12, and trunk.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-13 16:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-02 15:33 [Bug target/113723] New: -freorder-blocks-and-partition emits bogus asm directives on aarch64 redbeard0531 at gmail dot com
2024-02-02 15:43 ` [Bug target/113723] " redbeard0531 at gmail dot com
2024-02-04  0:49 ` [Bug rtl-optimization/113723] switch (jump) tables don't get along with -freorder-blocks-and-partition on non-x86 pinskia at gcc dot gnu.org
2024-06-13 16:39 ` andi-gcc at firstfloor dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).