Merge constant pools for small functions

Bug #625233 reported by Andrew Stubbs
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro GCC
Won't Fix
Low
Unassigned

Bug Description

There is no reason that each ARM function should have its own constant pool; multiple small functions in the same section can share a pool.

E.g.

The following program produces two small constant pools, but both could share one.

 f()
 {
   return 123456789;
 }

 g()
 {
   return 123456789;
 }

[CodeSourcery Tracker ID #798]

Changed in gcc-linaro:
importance: Undecided → Low
tags: added: armel
removed: arm
Revision history for this message
stevenb (steven-gcc) wrote :

This looks like gcc.gnu.org/PR9702 which was filed almost 8 years ago by the CSiBE folks. Apparently this used to be a hard problem. It may still be a hard problem now, but at least GCC has the ability now (GCC 4.6) to view entire compilation units (and more) so the problem should be easier to fix than 8 years ago.

Michael Hope (michaelh1)
tags: added: size task
Revision history for this message
Andrew Stubbs (ams-codesourcery) wrote :

AFAICT ARM doesn't seem to use the normal GCC constant pools mechanism, but instead implements its own "minipools".

These minipools are created by the TARGET_MACHINE_DEPENDENT_REORG pass (implemented by function arm_reorg). This pass is a per-function pass, so arm_reorg cannot modify the minipools attached to other functions. Is it possible to overcome this limitation?

Another observation: I'm not totally sure, but I think that the current upstream implementation is only capable of creating minipools *after* the reference point (i.e. at positive offsets). For small functions this is fine, but for large functions this might result in multiple minipools (one half way through, and one at the end, say) where only one would be necessary, were negative offsets allowed. There's clearly some small size benefit to be had here, but perhaps not much.

Viktor (vchong)
Changed in gcc-linaro:
status: New → Confirmed
Viktor (vchong)
Changed in gcc-linaro:
status: Confirmed → Won't Fix
Revision history for this message
Paolo (psubiaco-1) wrote :

This is a annoying problem for gcc, because waste rom space defining the same constant multi times
Another example: http://pastebin.com/Ljbm8LSA
the ARM instrcutions ldr Rd,LABEL
is able to to load into Rd a variable within address-space 1020 , so if functions are really small it makes not sense to define the same constant for each functions, but it's better to define the constant only once.
Thanks a lot. Paolo

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.