public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redbeard0531 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/113723] New: -freorder-blocks-and-partition emits bogus asm directives on aarch64
Date: Fri, 02 Feb 2024 15:33:47 +0000	[thread overview]
Message-ID: <bug-113723-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2024-02-02 15:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02 15:33 redbeard0531 at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-113723-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).