| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
| A couple of things jump to mind. It sounds like, despite the fact that the functions are declared "inline" or are inside the class definition (you didn't say if this was straight C or C++), the compiler is deciding that the functions aren't really going to be inlined after all, and so they end up being multiply-defined. There's a bunch of switches that control inlining. The first one to look at is -finline-limit=n, which specifies how big (in pseudo-instructions) an inline function can be. The default value is 600. Others control more intimate details. I've reproduced the relevant sections below. -finline-functions Integrate all simple functions into their callers. The compiler heuristically decides which functions are simple enough to be worth integrating in this way. If all calls to a given function are integrated, and the function is declared "static", then the function is normally not output as assembler code in its own right. Enabled at level -O3. -finline-limit=n By default, GCC limits the size of functions that can be inlined. This flag allows the control of this limit for functions that are explicitly marked as inline (i.e., marked with the inline keyword or defined within the class definition in c++). n is the size of functions that can be inlined in number of pseudo instructions (not counting parameter handling). The default value of n is 600. Increasing this value can result in more inlined code at the cost of compilation time and memory consumption. Decreasing usually makes the compilation faster and less code will be inlined (which presumably means slower programs). This option is particularly useful for programs that use inlining heavily such as those based on recursive templates with C++. Inlining is actually controlled by a number of parameters, which may be specified individually by using --param name=value. The -finline-limit=n option sets some of these parameters as follows: @item max-inline-insns-single is set to I<n>/2. @item max-inline-insns-auto is set to I<n>/2. @item min-inline-insns is set to 130 or I<n>/4, whichever is smaller. @item max-inline-insns-rtl is set to I<n>. See below for a documentation of the individual parameters control- ling inlining. Note: pseudo instruction represents, in this particular context, an abstract measurement of function's size. In no way, it represents a count of assembly instructions and as such its exact meaning might change from one release to an another. -fkeep-inline-functions In C, emit "static" functions that are declared "inline" into the object file, even if the function has been inlined into all of its callers. This switch does not affect functions using the "extern inline" extension in GNU C. In C++, emit any and all inline func- tions into the object file. [My guess is that you don't want to specify -fkeep-inline-functions -- jf] --param name=value In some places, GCC uses various constants to control the amount of optimization that is done. For example, GCC will not inline func- tions that contain more that a certain number of instructions. You can control some of these constants on the command-line using the --param option. The names of specific parameters, and the meaning of the values, are tied to the internals of the compiler, and are subject to change without notice in future releases. In each case, the value is an integer. The allowable choices for name are given in the following table: [snip] max-inline-insns-auto When you use -finline-functions (included in -O3), a lot of functions that would otherwise not be considered for inlining by the compiler will be investigated. To those functions, a different (more restrictive) limit compared to functions declared inline can be applied. The default value is 90. large-function-insns The limit specifying really large functions. For functions larger than this limit after inlining inlining is constrained by --param large-function-growth. This parameter is useful primarily to avoid extreme compilation time caused by non-lin- ear algorithms used by the backend. This parameter is ignored when -funit-at-a-time is not used. The default value is 2700. large-function-growth Specifies maximal growth of large function caused by inlining in percents. This parameter is ignored when -funit-at-a-time is not used. The default value is 100 which limits large func- tion growth to 2.0 times the original size. inline-unit-growth Specifies maximal overall growth of the compilation unit caused by inlining. This parameter is ignored when -funit-at-a-time is not used. The default value is 50 which limits unit growth to 1.5 times the original size. max-inline-insns-recursive max-inline-insns-recursive-auto Specifies maximum number of instructions out-of-line copy of self recursive inline function can grow into by performing recursive inlining. For functions declared inline --param max-inline-insns-recur- sive is taken into acount. For function not declared inline, recursive inlining happens only when -finline-functions (included in -O3) is enabled and --param max-inline-insns- recursive-auto is used. The default value is 450. max-inline-recursive-depth max-inline-recursive-depth-auto Specifies maximum recursion depth used by the recursive inlin- ing. For functions declared inline --param max-inline-recursive- depth is taken into acount. For function not declared inline, recursive inlining happens only when -finline-functions (included in -O3) is enabled and --param max-inline-recursive- depth-auto is used. The default value is 450. inline-call-cost Specify cost of call instruction relative to simple arithmetics operations (having cost of 1). Increasing this cost disqualify inlinining of non-leaf functions and at same time increase size of leaf function that is believed to reduce function size by being inlined. In effect it increase amount of inlining for code having large abstraction penalty (many functions that just pass the argumetns to other functions) and decrease inlining for code with low abstraction penalty. Default value is 16. Hope this helps, John Francini On 6 Oct 2006, at 16:48, Chris Edgington wrote:
|
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/email@hidden This email sent to email@hidden
| References: | |
| >Port from Win to OSX with Inline functions (From: Chris Edgington <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.