[FFmpeg-devel] Stack variables alignment check in libavcodec/dsputil.c
Thu Aug 2 01:06:28 CEST 2007
On Tue, 2007-07-31 at 02:00 +0200, Michael Niedermayer wrote:
> On Tue, Jul 31, 2007 at 02:47:59AM +0300, Uoti Urpala wrote:
> > > On Mon, Jul 30, 2007 at 03:42:54PM -0700, Roman Shaposhnick wrote:
> > > > Not to start yet another gcc flame war, but I'm sick and tired
> > > > of hearing what gcc is *supposed* to do and how much better it
> > > > is supposed to be if it *works*. Well, it doesn't work, I'm sorry.
> > > > Hence the efficiency becomes moot.
> > In your earlier message you mentioned "gcc 3.4.5". gcc versions before 4
> > are buggy and just ignore alignment for stack variables.
> > On Tue, 2007-07-31 at 01:12 +0200, Michael Niedermayer wrote:
> > > realign_stack() would check if the stack is aligned and if so just return 0
> > > if not it would align the stack, copy the function arguments to the aligned
> > > stack, call the function ptr, set ret to what the function returned and
> > > return 1
> > >
> > > yes you have to write realign_stack() in asm
> > In gcc-4.2 or above you can use function attributes to add such forced
> > stack realign code instead of writing asm. However since Roman mentioned
> > pre-4 gcc versions the problem in this case most likely isn't the stack
> > getting misaligned but gcc placing the variables at a bad offset from
> > the stack frame.
> ok, then my next idea would be to put the SSE/altivec code which needs an
> aligned stack under #ifdef ALIGNED_STACK
> its of course not a perfect solution but better than random crashes or
> having to disable all mmx/sse/...
The trouble is -- we've got quite a few places where DECLARE_ALIGNED
is used. Only some of those variable are critical to be aligned properly
for SSE/altivec and it isn't always clear which ones.
More information about the ffmpeg-devel