内联关键字是否会影响链接时间优化? [重复]

时间:2023-01-15 04:53:13

This question already has an answer here:

这个问题在这里已有答案:

If gcc get called with link time optimization (-flto) enabled and I am using one of the following keyword/attribute:

如果在启用链接时优化(-flto)的情况下调用gcc,并且我使用以下关键字/属性之一:

__attribute__((always_inline)) void foo(int i);
inline void bar(int i);

Does this keyword/attribute affect the behavior of the link-time optimization (If the compiler is not able to do the inlineing)?

此关键字/属性是否会影响链接时优化的行为(如果编译器无法进行内联)?

Does the link-time optimization prefer inlineing of these function over functions without this keyword/attribute.

链接时优化是否更喜欢在没有此关键字/属性的函数中内联这些函数。

The question is if it makes a difference for the linker-phase processing not the compiler.

问题是它是否对链接器阶段处理而不是编译器产生影响。

1 个解决方案

#1


2  

Based on a previous answer found here: what “inline __attribute__((always_inline))” means in the function?

基于此前找到的答案:“inline __attribute __((always_inline))”在函数中意味着什么?

__attribute__((always_inline))

makes the compiler try to inline it even if it's disabled in the preferences, and

使编译器尝试内联它,即使它在首选项中被禁用,并且

inline

tells the compiler to try really hard to inline the function.

告诉编译器真的很难内联函数。

#1


2  

Based on a previous answer found here: what “inline __attribute__((always_inline))” means in the function?

基于此前找到的答案:“inline __attribute __((always_inline))”在函数中意味着什么?

__attribute__((always_inline))

makes the compiler try to inline it even if it's disabled in the preferences, and

使编译器尝试内联它,即使它在首选项中被禁用,并且

inline

tells the compiler to try really hard to inline the function.

告诉编译器真的很难内联函数。