jrtc27 added a comment. In D79916#2279987 <https://reviews.llvm.org/D79916#2279987>, @MaskRay wrote:
> Several previous comments are FreeBSD specific. To we clang developers, the > concrete request is > >> Given that GCC will inline at -O, at least these days, ... > > right? I think this makes sense, especially when `inline` is explicitly > specified... This appears to be related to some -O1 work @echristo is working > on. > > // gcc -O1 and g++ -O1 inline `foo`. Note that in C99 mode, `extern int > foo` is needed to ask the compiler to provide an external definition. > // clang -O1 and clang++ -O1 do not inline `foo` > inline int foo(int a) { > return a + a; > } > > int bar(int a, int b) { > return foo(a + b); > } Yes, `inline` should certainly be inlined, but also non-`inline` things should too. Perhaps not so aggressively, but there's no good reason not to, really, it can be a big win with a simple transformation. GCC seems to inline even those: # echo 'static void foo(void) { __asm__ __volatile__ ("#asdf"); } void bar(void) { foo(); } void baz(void) { foo(); foo(); }' | gcc -x c - -o - -S -O1 .file "" .text .globl bar .type bar, @function bar: .LFB1: .cfi_startproc #APP # 1 "<stdin>" 1 #asdf # 0 "" 2 #NO_APP ret .cfi_endproc .LFE1: .size bar, .-bar .globl baz .type baz, @function baz: .LFB2: .cfi_startproc #APP # 1 "<stdin>" 1 #asdf # 0 "" 2 # 1 "<stdin>" 1 #asdf # 0 "" 2 #NO_APP ret .cfi_endproc .LFE2: .size baz, .-baz .ident "GCC: (Debian 10.2.0-8) 10.2.0" .section .note.GNU-stack,"",@progbits Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79916/new/ https://reviews.llvm.org/D79916 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits