https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88010
Bug ID: 88010 Summary: noinline function alias unexpectedly inlined Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- GCC appears to ignore attribute noinline on aliases whose target is a function declared inline and inline calls to those aliases even at -O0. (I noticed this while testing Glibc's uses of attributes alias and always_inline.) If the noinline attribute on the alias is deliberately ignored in favor of those on its target GCC should issue a warning. Otherwise, if the attribute on the alias should be respected then this is a codegen bug. $ cat t.c && gcc -O0 -S -Wall -Wextra -fdump-tree-optimized=/dev/stdout t.c __attribute__ ((always_inline)) static inline int finline (void) { return 1; } __attribute__ ((alias ("finline"))) int alias_finline (void); __attribute__ ((alias ("finline"))) inline int inline_alias_finline (void); __attribute__ ((alias ("finline"), noinline)) int noinline_alias_finline (void); int call_alias_finline (void) { return alias_finline (); // inlined (should it be?) } int call_inline_alias_finline (void) { return inline_alias_finline (); // inlined as expected } int call_noinline_alias_finline (void) { return noinline_alias_finline (); // unexpectedly inlined } ;; Function finline (finline, funcdef_no=0, decl_uid=1906, cgraph_uid=1, symbol_order=0) __attribute__((always_inline)) finline () { int D.1924; int _1; <bb 2> : _1 = 1; <bb 3> : <L0>: return _1; } ;; Function call_alias_finline (call_alias_finline, funcdef_no=1, decl_uid=1915, cgraph_uid=5, symbol_order=4) call_alias_finline () { int D.1937; int D.1936; int D.1926; int _2; int _3; <bb 2> : _3 = 1; <bb 3> : <L1>: _4 = _3; <bb 4> : _2 = _4; <bb 5> : <L0>: return _2; } ;; Function call_inline_alias_finline (call_inline_alias_finline, funcdef_no=2, decl_uid=1918, cgraph_uid=6, symbol_order=5) call_inline_alias_finline () { int D.1940; int D.1939; int D.1928; int _2; int _3; <bb 2> : _3 = 1; <bb 3> : <L1>: _4 = _3; <bb 4> : _2 = _4; <bb 5> : <L0>: return _2; } ;; Function call_noinline_alias_finline (call_noinline_alias_finline, funcdef_no=3, decl_uid=1921, cgraph_uid=7, symbol_order=6) call_noinline_alias_finline () { int D.1943; int D.1942; int D.1930; int _2; int _3; <bb 2> : _3 = 1; <bb 3> : <L1>: _4 = _3; <bb 4> : _2 = _4; <bb 5> : <L0>: return _2; }