我收到内部警告,例如:
warning: inlining failed in call to ‘symbol_Arity’: call is unlikely and code size would grow
为了摆脱这个,我更改了 makefile,删除了 -Winline 以摆脱这个。我没有收到任何内联警告。但是,我不知道在性能方面这样做有多明智。有人可以给我建议吗?
添加了更多信息:
这是警告:
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
对应的代码是:
来自 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 }
来自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 }
最佳答案
唯一的“问题”是您试图强制编译器做一些低效的事情。
使用 ìnline
而不是 __inline__
,并尊重编译器关于什么应该或不应该内联的决定。不要试图强制执行它,除非您已经分析了代码,发现它是一个瓶颈,并且证实内联实际上会加速而不是减慢代码。 p>
这基本上就是警告所说的内容:“你要求我做一些愚蠢的事情,这会减慢代码速度。我将忽略它”。
当然,您可以忽略(或静音)该警告,但最好的解决方案是一开始就不要强制它做任何愚蠢的事情。不要使用特定于编译器的 __inline__
,如果需要则使用 inline
,并相信编译器会决定内联什么。
关于c - 抑制内联警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2798589/