[FFmpeg-devel] Question about -fPIC usage for some files

Alexander Strange astrange
Fri Feb 8 22:48:43 CET 2008

On Feb 8, 2008 4:26 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Fri, Feb 08, 2008 at 01:03:56PM -0800, Trent Piepho wrote:
> > On Fri, 8 Feb 2008, Thorsten Jordan wrote:
> > > > Why does it fail with pic for you?
> > > the same problem that was discussed several times on this list, gcc
> > > fails to generate the code because it runs out of registers (ebx is used
> > > with -fPIC):
> >
> > Since version 3 something, gcc can use other registers besides ebx, and
> > might not use ebx at all if the function doesn't do anything that requires
> > access to the pic pointer.  If a function accesses no globals, does not
> > take the address of a fuction, or call a function in another shared
> > library, it shouldn't need to load the pic register.
> >
> > The real problem isn't ebx, it's accessing globals.  In non-PIC code, a
> > memory reference to a global takes zero registers.  In PIC code, it takes
> > one register.  In some cases multiple global references can share the same
> > register(s), so gcc doesn't always need one per global.  But this could
> > still easily add a half dozen extra registers to an asm block.
> [...]
> Why does it fail?
> This is not a compiler being presented with a situation too complex to solve
> This is a compiler failing to fit a grain of sand in a bus.

apply_welch_window_sse2 has six constraints:
        :"+&r"(i), "+&r"(j)\
        :"r"(w_data+n2), "r"(w_data+len-2-n2),\
         "r"(data+n2), "r"(data+len-2-n2)\

It only fails if that's inlined; I think the VLA use is breaking it:
    double tmp[len + lag + 2];

If you comment out everything below line 78 it still fails.

More information about the ffmpeg-devel mailing list