On Fri, Dec 21, 2012 at 4:41 AM, Richard Biener <richard.guent...@gmail.com> wrote: > > On Thu, Dec 20, 2012 at 5:33 PM, Adam <adam.j.le...@gmail.com> wrote: > > Hi, > > > > When using -flto is there a way to tell gcc to not inline a particular > > function? attribute noinline appears to have no effect. I am using gcc > > 4.7.2. The use case is for certain functions that cause optimization > > problems when they are inlined. An example is when the function is throwing > > a c++ exception. > > attribute noinline should have the desired effect (you may need > noclone as well). >
Richard, Doesn't seem to work for me. Here is what I am trying: func.hpp ( I have tried this with various combinations and orderings of noinline, noclone ): void my__func() __attribute__((noinline)) __attribute__ ((noclone)); func.cpp: #include <cstdio> void my__func() { printf("prnting"); } main.cpp #include "func.hpp" int main() { my__func(); return 0; } then: g++ -O3 -g -flto main.cpp func.cpp -o lto_inline_test I load up gdb, break main, run. disassemble and see that it is directly calling printf instead of my__func. gcc -v: Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.2-11precise2' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-11precise2) Any thoughts? > Richard. > > > Thanks, > > Adam