[FFmpeg-devel] [PATCH] Export MANGLE definition

Uoti Urpala uoti.urpala
Sat Dec 15 21:32:30 CET 2007

On Sat, 2007-12-15 at 20:41 +0100, Michael Niedermayer wrote:
> On Sat, Dec 15, 2007 at 07:06:05PM +0100, Reimar D?ffinger wrote:
> yes
> MANGLE gurantees direct, zero overhead and fast access
> asm arguments are at the mercy of gccs optimizer and absolutely require
> vissibility attributes to be specified
> for it to be equally efficient gcc must
> 0. have vissibility attributes specified for all global variables
> 1. realize that the code does not need indirection through thr GOT
> 2. realize that now after 1. it no longer needs the code to init ebx

But these are not in any way specific to asm. The same applies to all C
code. If you worry about this overhead then you need visibility
attributes anyway (unless access to global constants/variables from C
code is way rarer than once per such asm block on average - I guess it
is not).

> now if gccs asm was known to be solid and bugfree then no doubt asm arguments
> would be the way to go but gcc is a buggy pile of ... so things are:
> advantage:
>  purely stylistic and philosophical, you trade MANGLE against
>  attribute visibility

Even if you consider "trading MANGLE against attribute visibility" to be
an even trade from the stylistic viewpoint, it's a win from the
performance viewpoint as it improves C performance. Using asm arguments
is also an advantage from the code correctness viewpoint. There's no
requirement for "static const int foo[] = {1, 2, 3};" to produce
anything resembling a table of three integers if "foo" is not used as an
asm argument or its address given to outside code (and for static
variables you don't need visibility attributes either).

> disadvantage:
>  extreemly fragile code if it works at all, gcc 3.3 failed as you said yourself

As explained above MANGLE is not exactly robust either. There's no
reason why it would be "extremely" fragile any more than asm in general
(which is not a particularly robust part of gcc).

> i much prefer to have a hard error and can point at gcc instead of having one
> of 500 asms have 4 unneeded GOT indirections before the asm and have ffmpeg
> be 50% slower on some obscure OS and have users report that <random commercial
> codec> is twice as fast as only hint that there may be something wrong ...

Again, there is nothing asm-specific about the efficiency of variable

> btw, heres some experiment:

This also shows only that access to globals without visibility
attributes is less efficient. I think it doesn't make sense to try using
MANGLE as a limited-to-asm-only workaround for that.

More information about the ffmpeg-devel mailing list