Inlining vs the stack

Mike Stump mrs@apple.com
Fri Aug 12 20:53:00 GMT 2005


On Aug 12, 2005, at 12:25 PM, Paul Koning wrote:
>  Mike> I think we should turn off inlining for functions > 100k stack
>  Mike> size.  (Or maybe 500k, if you want).
>
> Why should stack size be a consideration?  Code size I understand, but
> stack size doesn't seem to matter.

In general you'll want to understand how OSes allocate stack, and how  
the determine if an access is to the stack or not.  The canonical  
unix way is to catch a fault, and if that fault is within X MB (8MB  
in years past) of the top of the stack, assume that the access is  
meant for the stack, extend it, and then retry the instruction.  If  
the access is X+1 MB away, the program dies a horrible death.  This  
line is arbitrary, exists, and is the difference between a running  
application and one that dies.

Any transformation that increases the stack size from X to X + 1 is  
an invalid transformation.  Currently, inlining can do this, and it  
is wrong.  X can be run time selectable, OMF selectable, OS defined...



More information about the Gcc mailing list