public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Trevor Blackwell <tlb@tlb.blackwells.net> To: gcc-gnats@gcc.gnu.org Subject: optimization/7226: Spurious "output number 1 not directly addressable" error with asm =m constraint Date: Sat, 06 Jul 2002 17:46:00 -0000 [thread overview] Message-ID: <200207070042.g670gKb46641@tlb.blackwells.net> (raw) >Number: 7226 >Category: optimization >Synopsis: gcc -O can't compile some asm functions with memory operands >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: ice-on-legal-code >Submitter-Id: net >Arrival-Date: Sat Jul 06 17:46:02 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Trevor Blackwell >Release: 3.1.1 20020617 (prerelease) [FreeBSD] >Organization: >Environment: System: FreeBSD tlb.blackwells.net 4.5-RELEASE-p2 FreeBSD 4.5-RELEASE-p2 #3: Sat Mar 9 12:32:15 PST 2002 root@tlb.umbrellaresearch.com:/d1/usr-obj/usr/src/sys/TLB i386 host: i386-portbld-freebsd4.5 build: i386-portbld-freebsd4.5 target: i386-portbld-freebsd4.5 configured with: ./..//gcc-20020617/configure --disable-nls --with-gnu-as --with-gnu-ld --with-gxx-include-dir=/usr/local/lib/gcc-lib/i386-portbld-freebsd4.5/3.1.1/include/g++ --disable-libgcj --disable-shared --prefix=/usr/local i386-portbld-freebsd4.5 >Description: When I compile, I get: $ g++31 -O -o t-gcc-asm t-gcc-asm.cc t-gcc-asm.cc: In function `int main()': t-gcc-asm.cc:13: output number 1 not directly addressable The asm function below should set foo=13 and bar=14. It works if you compile with -O0, or if you declare bar volatile. It works if you add a (pointless) statement &bar; ahead of the asm, to force bar into memory. It works if you make it be a C program instead of C++. gcc 2.95.3 compiles it OK, either as C++ or C. Presumably the =m constraint isn't forcing the operand to memory like it should. I don't see the same problem with only 1 "=m" operand. >How-To-Repeat: Compile this C++ program with -O. Add -DFIX1 or -DFIX2 for workarounds. ---- t-gcc-asm.cc --- extern "C" int printf(const char *, ...); int main() { int foo; #ifdef FIX1 volatile int bar; #else int bar; #endif #ifdef FIX2 &bar; #endif asm("push %%eax;" "mov $13, %%eax;" "mov %%eax, %0;" "mov $14, %%eax;" "mov %%eax, %1;" "pop %%eax;" : "=m" (foo), "=m" (bar)); printf("foo=%d bar=%d\n",foo,bar); } ----------------------- >Fix: - Declare bar volatile. - Use a register constraint (but this doesn't work in my application, because it's already using all available registers.) - Take the address of bar somewhere in the function. >Release-Note: >Audit-Trail: >Unformatted:
reply other threads:[~2002-07-07 0:46 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200207070042.g670gKb46641@tlb.blackwells.net \ --to=tlb@tlb.blackwells.net \ --cc=gcc-gnats@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: linkBe 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).