How to emit optimization reports

Hi all,

according to the documentation, clang supports options to emit optimisation reports. However, when I try to use them, I get an error:

$ clang test.cpp -c -Rpass=inline

clang: error: unknown argument: '-Rpass=inline’

Am I doing something wrong? I am using this version of clang:

$ clang --version

Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)

Target: x86_64-apple-darwin14.0.0

Thread model: posix

Thanks for your help, and kind regards,

Björn Pollex

Hi all,

according to the documentation, clang supports options to emit
optimisation reports
<http://llvm.org/releases/3.5.0/tools/clang/docs/UsersManual.html#options-to-emit-optimization-reports>.
However, when I try to use them, I get an error:

$ clang test.cpp -c -Rpass=inline
clang: error: unknown argument: '-Rpass=inline’

It looks like your version of clang is too old for the remark flags.

Also, you didn't pass any optimization flags so the inliner won't fire
(except __attribute__((always_inline)) maybe?). You probably wanted to add
-O2 too.

$ clang -c -Rpass=inline hello.cpp -O2
In file included from hello.cpp:1:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/iostream:39:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:38:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ios:44:
*/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/basic_ios.h:152:21:
remark: _ZNKSt9basic_iosIcSt11char_traitsIcEE7rdstateEv inlined into*
* _ZNSt9basic_iosIcSt11char_traitsIcEE8setstateESt12_Ios_Iostate
[-Rpass=inline]*
      { this->clear(this->rdstate() | __state); }
* ^*
*/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/basic_ios.h:152:21:
remark: _ZStorSt12_Ios_IostateS_ inlined into*
* _ZNSt9basic_iosIcSt11char_traitsIcEE8setstateESt12_Ios_Iostate
[-Rpass=inline]*
In file included from hello.cpp:1:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/iostream:39:
*/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:533:2:
remark: _ZNSt9basic_iosIcSt11char_traitsIcEE8setstateESt12_Ios_Iostate
inlined into*
* _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
[-Rpass=inline]*
        __out.setstate(ios_base::badbit);
* ^*
*/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:536:29:
remark: _ZNSt11char_traitsIcE6lengthEPKc inlined into
_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc*
* [-Rpass=inline]*
                         static_cast<streamsize>(_Traits::length(__s)));
* ^*
*hello.cpp:4:3: remark:
_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc inlined into main
[-Rpass=inline]*
  std::cout << "Hello world!\n";
* ^*
*remark: *__cxx_global_var_init inlined into _GLOBAL__sub_I_hello.cpp
[-Rpass=inline]
*note: *could not determine the original source location for
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/ios_base.h:0:0

$ clang -v
clang version 3.6.0 (trunk 222301)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Am I doing something wrong? I am using this version of clang:

$ clang --version
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

This isn't an llvm.org release, you'd have to contact Apple for support. It
looks like an XCode version to me.

Nick

Thanks for your help, and kind regards,

Nick,

thanks for the response. After switching to an llvm.org release of clang, everything works as documented!

Cheers,

Björn