[FFmpeg-devel] [PATCH] Fix missing used attribute for inline assembly variables

Michael Niedermayer michael at niedermayer.cc
Thu Nov 2 01:38:12 EET 2017


Hi

On Wed, Nov 01, 2017 at 07:25:08AM -0700, Teresa Johnson wrote:
> On Tue, Oct 31, 2017 at 5:42 PM, Michael Niedermayer <michael at niedermayer.cc
> > wrote:
> 
> > Hi
> >
> > On Tue, Oct 31, 2017 at 04:29:18PM +0000, Teresa Johnson wrote:
> > > It's needed for the same reason the used attribute was already added to
> > the
> > > "static const" variables. For those, when building with just -O2, they
> > > could be removed by optimization since they had local (file) scope, and
> > we
> > > couldn't see the uses in the inline assembly (without the used
> > attribute).
> > > With ThinLTO we have whole program scope, so even though they are
> > > non-static and have global scope we can do dead code elimination on them
> > if
> > > we don't see that they are used.
> >
> > currently we add "used" to DECLARE_ASM_CONST()
> > which is specific to inline asm use.
> >
> > DECLARE_ALIGNED() is not specific to use in asm.
> >
> > For DECLARE_ASM_CONST() the "used" is unneeded only in the subset of
> > inline asm cases where it is accessed through the asm operands like:
> >     __asm__ volatile(
> >         "movq          %0, %%mm7    \n\t"
> >         "movq          %1, %%mm6    \n\t"
> >         ::"m"(red_16mask),"m"(green_16mask));
> >
> > The compiler has full vissibility here of the access and if it removes
> > it its a  compiler bug.
> >
> > this is compared to code like:
> >  "pand "MANGLE(mask24l)", %%mm0\n\t"
> >
> > Here the compiler has no easy vissibility of the use, it is part of
> > the asm string.
> >
> > and comparing this to DECLARE_ALIGNED(), the big difference is
> > that DECLARE_ALIGNED() is used by plain C code which never should need
> > "used". So adding "used" to DECLARE_ALIGNED() would add alot more
> > "unused detection overriding" than what is needed
> >
> 
> Perhaps then an additional macro is needed for variables that are currently
> DECLARED_ALIGNED but used by MANGLE, which adds the used attribute. What do
> you suggest?

Ive no specific suggestion, but a 2nd macro seems a option

thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20171102/775ad6a6/attachment.sig>


More information about the ffmpeg-devel mailing list