public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: avbidder@acter.ch To: gcc-gnats@gcc.gnu.org Cc: avbidder@acter.ch Subject: target/4855: arm (thumb) backend generates illegal strb instruction Date: Thu, 01 Nov 2001 13:37:00 -0000 [thread overview] Message-ID: <200111120937.fAC9b8e24060@atlas.acter.ch> (raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 3643 bytes --] >Number: 4855 >Category: target >Synopsis: arm (thumb) backend generates illegal strb instruction >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Mon Nov 12 01:46:00 PST 2001 >Closed-Date: >Last-Modified: >Originator: Adrian von Bidder >Release: 3.0.2 >Organization: Acter AG, Zürich, Switzerland >Environment: System: Linux atlas 2.4.14 #2 Wed Nov 7 14:03:16 CET 2001 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: arm-linux-elf configured with: ../gcc-3.0.2.orig/configure --prefix=/home/avbidder/gcc-3 --target=arm-linux-elf --with-cpu=arm7tdmi --enable-checking >Description: gcc produces a 'strb rX, [sp, #offs]' instruction, which is not possible on the ARM with thumb code (only low registers are allowed in str/ldr, since there are only 3 bits of register address in the opcode.) Of course, the assembler does complain. Although the bug does not show up with the sample code and without optimizations it's not an optimizer bug - the backend should not be able to generate this instruction at all. >How-To-Repeat: The bug is quite robust. It occurs with arm-linux-elf-gcc -mthumb -fpic -mpic-register=r6 -O2 optionally, -O3, -msingle-pic-base, -mthumb-interwork and/or -g do not make the bug go away. $ arm-linux-elf-gcc -O2 -mthumb -fpic -mpic-register=r6 01.c /tmp/ccd0bSpI.s: Assembler messages: /tmp/ccd0bSpI.s:27: Error: byte or halfword not valid for base register With === strb r3, [sp, #1] !!!!!! === as the generated instruction . It should probably do something like mov rX, sp strb r3, [rX, #1] where X is in [0..7]. Or use a low register to address the stack at all? Boiled down as far as I could (it's an excerpt from regex.c in uclibc): [cut down preprocessor output from the original file.] === typedef enum { REG_NOERROR = 0, REG_NOMATCH, REG_BADPAT, REG_ECOLLATE, REG_ECTYPE, REG_EESCAPE, REG_ESUBREG, REG_EBRACK, REG_EPAREN, REG_EBRACE, REG_BADBR, REG_ERANGE, REG_ESPACE, REG_BADRPT, REG_EEND, REG_ESIZE, REG_ERPAREN } reg_errcode_t; typedef unsigned long int reg_syntax_t; extern int strcoll (const char *__s1, const char *__s2); static reg_errcode_t compile_range (p_ptr, pend, translate, syntax, b) const char **p_ptr, *pend; char *translate; reg_syntax_t syntax; unsigned char *b; { unsigned this_char; const char *p = *p_ptr; reg_errcode_t ret; char range_start[2]; char range_end[2]; char ch[2]; // if (p == pend) // return REG_ERANGE; // range_start[0] = p[-2]; // range_start[1] = '\0'; // range_end[0] = p[0]; // range_end[1] = '\0'; // (*p_ptr)++; ret = syntax & ((((((((((((((((((unsigned long int) 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ? REG_ERANGE : REG_NOERROR; ch[1] = '\0'; for (this_char = 0; this_char <= (unsigned char) -1; ++this_char) { ch[0] = this_char; if (strcoll (range_start, ch) <= 0 && strcoll (ch, range_end) <= 0) { (b [((unsigned char) ((translate ? (char) translate[(unsigned char) (this_char)] : (this_char)))) / 8] |= 1 << (((unsigned char) (translate ? (char) translate[(unsigned char) (this_char)] : (this_char))) % 8)); // ret = REG_NOERROR; } } return ret; } === >Fix: Don't use -On, n>1. Probably the fix will be a modification in arm.md. >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2001-11-12 9:46 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-11-01 13:37 avbidder [this message] 2002-01-22 13:26 pb
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=200111120937.fAC9b8e24060@atlas.acter.ch \ --to=avbidder@acter.ch \ --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).