public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "andrey.vihrov at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug inline-asm/101438] New: Compiler hang on inline asm with local register and VLA operands
Date: Tue, 13 Jul 2021 14:36:05 +0000	[thread overview]
Message-ID: <bug-101438-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 101438
           Summary: Compiler hang on inline asm with local register and
                    VLA operands
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: inline-asm
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andrey.vihrov at gmail dot com
  Target Milestone: ---
            Target: x86_64-pc-linux-gnu

Compiling this C source:

  int main(void)
  {
    register long long rax __asm__("rax") = 0;
    register long long rbx __asm__("rbx") = 0;
    register long long rcx __asm__("rcx") = 0;
    register long long rdx __asm__("rdx") = 0;
    register long long rsi __asm__("rsi") = 0;
    register long long rdi __asm__("rdi") = 0;
    register long long r8  __asm__("r8")  = 0;
    register long long r9  __asm__("r9")  = 0;
    register long long r10 __asm__("r10") = 0;
    register long long r11 __asm__("r11") = 0;
    register long long r12 __asm__("r12") = 0;
    register long long r13 __asm__("r13") = 0;
    register long long r14 __asm__("r14") = 0;
    register long long r15 __asm__("r15") = 0;

    volatile int x = 1;
    char arr[x];

    __asm__ (""
      :
      : "r"(rax),
        "r"(rbx),
        "r"(rcx),
        "r"(rdx),
        "r"(rsi),
        "r"(rdi),
        "r"(r8),
        "r"(r9),
        "r"(r10),
        "r"(r11),
        "r"(r12),
        "r"(r13),
        "r"(r14),
        "r"(r15),
        "m"(arr)
    );
  }

with "gcc -O1 test.c" causes the compiler to hang in an infinite loop.

Note: This code could possibly be formally incorrect, as [1] warns about
potential clobbering after initialization of local register variables. 

[1] https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html

             reply	other threads:[~2021-07-13 14:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13 14:36 andrey.vihrov at gmail dot com [this message]
2021-07-14  6:07 ` [Bug inline-asm/101438] " rguenth at gcc dot gnu.org
2021-07-14 18:26 ` pinskia at gcc dot gnu.org
2021-07-14 19:11 ` andrey.vihrov at gmail dot com
2022-07-30 11:26 ` [Bug target/101438] Compiler hang on inline asm with local register and alloca andrey.vihrov at gmail dot com
2022-08-02  6:18 ` andrey.vihrov at gmail dot com

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-101438-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).