This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: Preserving order of functions and top-level asms via cgraph


> Daniel Jacobowitz wrote:
> >This has been on the table for ages, but no one's gotten around to doing 
> >it. I'm attaching a (mostly untested) patch which fixes the simple cases.  
> >For
> >instance, it causes this test to come out in the expected order:
> >
> >void func1() { }
> >asm ("# ASM");
> >void func2() { }
> >
> >It doesn't handle variable declarations, and it won't be useful until it
> >does.  Right now declarations are written to the assembly file early, 
> >before
> >functions are assembled.  Steven pointed out (thank you, Steven) that this
> >is much easier on the tree-profiling branch, where that is no longer the
> >case.  So, I'm not going to extend the patch to declarations until that
> >piece is merged.
> >
> >In the mean time, any fundamental objections to the approach?
> 
> Your primary objective (get rid of -fno-unit-at-a-time) is one that I 
> strongly support.  I also agree that your strategy of recording asms in 
> cgraph makes sense, assuming that we want to continue to support 
> interleaving asms and other things, with well-defined ordering.
> 
> My only question is whether we do want to continue to support that 
> ordering.  In your example program, the compiler might someday notice 
> that func1 and func2 were identical, and emit a single function, with 
> two aliases.  There are other situations where moving things across an 
> asm might make sense, and if the translation unit depends on the 
> positioning of asms, there are likely things that the compiler doesn't 
> fully understand about the translation unit, which seems dangerous.  (In 
> other words, the asms aren't orthogonal to the rest of the translation 
> unit, but the compiler doesn't know in what ways they are non-orthogonal.)

Cgraph already optimizes function ordering to come out in topological
order so we can propagate some infromation during compilation.  We also
delay emitting variables until very end of compilation so we know what
variable uses has been completely optimized out, so I would preffer not
fixing ordering of things in assembly file.
We might thing of something like this for -O0 or so and it might be
fairly easy to implement if we still want to sick on this.

I also like killing -fno-unit-at-a-time by all my heard :)
> 
> Saving up all the asms and then emitting them either at end-of-file 
> might make sense.
> 
> I do understand that there are some things that one can do with the 
> current system that one probably couldn't under my proposal, but I'm not 
> sure if they're sufficiently compelling.  They might well be; I just 
> don't know.

Most common use are the function sections that we have attribute mechanizms
for now, so hopefully there is not that much use for this...
Problem is that attributes afaik does not work everywhere and we still
use this asm trick while bulding runtime.

Honza
> 
> -- 
> Mark Mitchell
> CodeSourcery, LLC
> mark@codesourcery.com
> (916) 791-8304


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]