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]

Stack Reorganization Patch


Hi Everyone,

Some time back we had a discussion on layout of locals
on stack at (http://gcc.gnu.org/ml/gcc/2002-05/threads.html#02838).
With that in mind, here is a patch which delays assignment of hard 
stack slots till after register allocation. It works as follows.

A call to assign_stack_local_1 is intercepted and we return a rtx
of the form (mem:mode reg/f/c:Pmode regno) for each requested stack slot
instead of normal form (mem:mode (plus:Pmode fp const_int offset)).
Note that the special flag /c is used to tell that this is 
stack address pseudo. The register allocator should not try to 
allocate any hard reg for this because it is already a known 
stack slot.After register allocation, we sort the allocated stack 
slots by size and number of references and convert it to normal
"fp + offset" form. We also have to mark them live at end of 
each basic block.

I  get some improvements in some benchmarks (5-6%)
(but unfortunately some regressions too)with this patch 
and would like that people have a look at it and It would 
be great if it makes a useful feature.

I have added the -fstack-reorg option to enable this patch at the 
moment so that it does not cause any problem with existing scheme of
things and can be tested separately. In addition to using -fstack-reorg
we need to define TARGET_REORGANIZE_STACK_P for a particular target 
to enable this feature.

I would like to thank Zack Weinberg for the basic idea. And I would also 
thank Joern Rennecke, Alexandre Oliva, Joe Buck, Gary Funck, Richard Kenner,
Jan Hubicka for useful inputs.

Please let me know the issues, changes required so that this patch 
can be put in GCC.

This part of the patch contains changes in existing gcc files. A new 
file gcc/stack_reorg.c is added.

KNOWN PROBLEMS:
   * The feature does not work with "-fnew-ra" option at present. 
     It can be fixed. I will be working on it.
   * Nested functions, Non Local Labels cannot be supported.
     So locals will not be reorganized if function contains nested functions
     or is itself a nested function.

Please find attached gzip of the ChangeLog, the patch to existing files and
the new file gcc/stack_reorg.c.

Thanks for your precious attention.

Best Regards,
  Naveen Sharma.

Attachment: stack_reorg.tar.gz
Description: Binary data


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