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

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

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

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]

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


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