0

C でプロジェクトに取り組んでいます。コンパイルすると、次のエラーが発生します。

warning: inlining failed in call to 'xyz()'  --param max-inline-insns-single limit reached

また、コンパイラは警告をエラーとして報告しますが、これを回避したくありません。

では、これはインライン関数の入れ子が多すぎるためでしょうか? それを機能させるためにできることはありますか(関数をインラインで宣言しないことを除いて)?

ありがとう!

4

2 に答える 2

4

gcc docsが指摘しているように:

max-inline-insns-single:

いくつかのパラメーターは、gcc で使用されるツリー インライナーを制御します。この数は、ツリー インライナーがインライン化を考慮する単一の関数内の命令の最大数 (GCC の内部表現でカウントされる) を設定します。これは、インラインで宣言された関数と、クラス宣言 (C++) で実装されたメソッドにのみ影響します。デフォルト値は 500 です。

それでも警告をエラーとして扱いたい場合 (不当な要求ではありません)、以下を使用してください。

--param max-inline-insns-single=1000

(またはさらに大きな値) を使用して、デフォルトから値を上げます。

于 2013-07-03T02:07:44.343 に答える
0

gcc/g++ は、inliner.

-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:

max-inline-insns-single
is set to n/2. 
max-inline-insns-auto
is set to n/2. 
min-inline-insns
is set to 130 or n/4, whichever is smaller. 
max-inline-insns-rtl
is set to n.

したがって、できることは の値を増やすことですn。インライン化を手動で行うのは良い考えではありませんが (コンパイラはこれが得意です)。

詳しくはこちらまたはman gcc

于 2013-07-03T02:13:09.297 に答える