开发者

Supressing inlining warning

I am getting inling warning such as :

  warning: inlining failed in call to ‘symbol_Arity’: call is unlikely and code size would grow

To get rid of this i changed the makefile removing the -Winline to get rid of this. I don't get any inlining warning. But , i don't know how wise is it to do in respect of performance. Can anybody please suggest me about it?

Added some more information:

here is th warning:

search.c: In function ‘prfs_InsertInSortTheories’:
list.h:254: warning: inlining failed in call to ‘list_Delete’: call is unlikely and code size would grow
search.c:187: warning: called from here
list.h:254: warning: inlining failed in call to ‘list_Delete’: call is unlikely and code size would grow
search.c:189: warning: called from here

and the corresponding code is:

from list.h

254 static __inline__ void list_Delete(LIST L)
255 {
256  开发者_运维知识库 LIST Current;
257 
258   Current = L;
259   while (!list_Empty(Current)) {
260     L = list_Cdr(L);
261     list_Free(Current);
262     Current = L;
263   }

and from search.c

 176     LIST    approx;
 177     l = clause_Length(Clause);
 178     for (i = clause_FirstSuccedentLitIndex(Clause); i < l; i++) {
 179       lit = clause_GetLiteral(Clause,i);
 180       if (clause_LiteralIsMaximal(lit) &&
 181           symbol_IsBaseSort(term_TopSymbol(clause_LiteralSignedAtom(lit)))) {
 182         if (prfs_DynamicSortTheory(Search) != (SORTTHEORY)NULL
 183             && clause_NumOfSuccLits(Clause) == 1 &&
 184             clause_NumOfAnteLits(Clause) == 0)
 185           {
 186           copy = clause_Copy(Clause);
 187           list_Delete(clause_ParentClauses(copy));
 188           clause_SetParentClauses(copy,list_Nil());
 189           list_Delete(clause_ParentLiterals(copy));
 190           clause_SetParentLiterals(copy,list_Nil());
 191           clause_SetNumber(copy,clause_Number(Clause));
 192           sort_TheoryInsertClause(prfs_DynamicSortTheory(Search),Clause,
 193                                   copy,clause_GetLiteral(copy,i));
 194         }


The only "problem" is that you're trying to force the compiler to do something inefficient.

Use ìnline rather than __inline__, and respect the compilers decisions on what should or should not be inlined. Don't try to force it, unless you've already profiled the code, found it to be a bottleneck, and verified that inlining would actually speed up, rather than slow down, the code.

That's essentially what the warning is saying: "you're asking me to do something stupid that'd slow down the code. I'm going to ignore it".

And sure, you can ignore (or silence) the warning, but the best solution is just to not force it to do anything stupid in the first place. Don't use the compiler-specific __inline__, and use inline if you need it, and trust the compiler to decide what to inline.


Remove static __inline__ from the function in the header file and replace it with inline - the C++ standard keyword. You shouldn't get a warning with that.


I stumbled here after compiling some old code with -Werror -Winline - a warning that i want on by default because it finds significant errors, where you have forgotten assignment operators etc.

However, for a particular function i absolutely do need it to be always inlined, and hence i needed a way to suppress a warning for just this block of code.

#pragma GCC diagnostic ignored "-Winline"

Was the obvious choice, but it actually does not suppress this warning. Solution is to use attribute always_inline:

inline bool function() __attribute__((always_inline));
inline bool function() { /*something*/ };

This will get rid of the warning and actually always force inlining


I don't see a problem with that!

There shouldn't be a performance lag, as I understand, coz, the compiler treats the inline as a regular function!

See what GCC has to say!

-Winline
Warn if a function can not be inlined and it was declared as inline. Even with this option, the compiler will not warn about failures to inline functions declared in system headers. The compiler uses a variety of heuristics to determine whether or not to inline a function. For example, the compiler takes into account the size of the function being inlined and the amount of inlining that has already been done in the current function. Therefore, seemingly insignificant changes in the source program can cause the warnings produced by -Winline to appear or disappear.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜