Bug 78091 - i386: Register allocation failure with -Os
Summary: i386: Register allocation failure with -Os
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-24 08:54 UTC by Florian Weimer
Modified: 2016-10-24 09:08 UTC (History)
0 users

See Also:
Host:
Target: i386
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
posix_fallocate.i (275 bytes, text/plain)
2016-10-24 08:54 UTC, Florian Weimer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Weimer 2016-10-24 08:54:19 UTC
Created attachment 39874 [details]
posix_fallocate.i

The attached test case has been extracted from this glibc bug report:

  https://sourceware.org/bugzilla/show_bug.cgi?id=20729

We were under the impression that starting with GCC 5, we could issue six-argument system calls (which need all registers except %esp) directly from inline assembly.  Usually, this works, but it's clear that register allocation is difficult under these circumstances.  With “-m32 -Os”, the test case fails with:

posix_fallocate.i: In function ‘posix_fallocate’:
posix_fallocate.i:24:1: error: bp cannot be used in asm here
 }
 ^
posix_fallocate.i:24:1: error: bp cannot be used in asm here

This happens with:

gcc version 5.3.1 20160406 (Red Hat 5.3.1-6) (GCC) 
gcc version 7.0.0 20160518 (experimental) (GCC) 

If this cannot be fixed in GCC itself, we need a reliable compile-time test to discover optimizer settings which cause this at configure time.
Comment 1 Uroš Bizjak 2016-10-24 09:02:32 UTC
-fomit-frame-pointer
Comment 2 Florian Weimer 2016-10-24 09:06:39 UTC
(In reply to Uroš Bizjak from comment #1)
> -fomit-frame-pointer

Ugh, of course.  I was confused.  Thanks.

The glibc build environment used by the reporter is obviously incorrect.
Comment 3 Florian Weimer 2016-10-24 09:08:52 UTC
Although I have to admit, the error variable could be a bit nicer, rejecting the register variable definition.