简体   繁体   English

Clang ++ PGO:空.profraw

[英]Clang++ PGO: empty .profraw


I'm asking for help for a problem with Clang Profile Guided Optimization. 我正在寻求Clang Profile Guided Optimization问题的帮助。 I'm using clang++-3.7, but the problem is still present with clang++-3.6. 我正在使用clang ++ - 3.7,但问题仍然存在于clang ++ - 3.6中。
If I try to do the PGO with a dummy code, everything's fine: 如果我尝试使用虚拟代码进行PGO,一切都很好:

  • I compile with -fprofile-instr-generate: 我用-fprofile-instr-generate编译:
    clang++ -o test -fprofile-instr-generate dummy.cpp clang ++ -o test -fprofile-instr-generate dummy.cpp
  • The executable "test", when launched, generates a default.profraw file 可执行文件“test”在启动时会生成default.profraw文件
  • I can merge the profiles with llvm-profdata merge 我可以将配置文件与llvm-profdata合并合并
  • At the end I can compile with the profiles integration, with -fprofile-instr-use on the .profdata 最后,我可以使用.profdata上的-fprofile-instr-use进行配置文件集成
  • But with a bigger project there are some problems. 但是对于一个更大的项目,存在一些问题。 I use a makefile and a script to automate the process, but this is the operations flow: 我使用makefile和脚本来自动化该过程,但这是操作流程:

  • I compile the sources containing the classes creating the object files: 我编译包含创建目标文件的类的源:
    clang++ -c --std=c++0x -O3 -flto -fprofile-instr-generate src/foo1.cpp -o obj/foo1.o clang ++ -c --std = c ++ 0x -O3 -flto -fprofile-instr-generate src / foo1.cpp -o obj / foo1.o
    clang++ -c --std=c++0x -O3 -flto -fprofile-instr-generate src/foo2.cpp -o obj/foo2.o clang ++ -c --std = c ++ 0x -O3 -flto -fprofile-instr-generate src / foo2.cpp -o obj / foo2.o
    clang++ -c --std=c++0x -O3 -flto -fprofile-instr-generate src/foo3.cpp -o obj/foo3.o clang ++ -c --std = c ++ 0x -O3 -flto -fprofile-instr-generate src / foo3.cpp -o obj / foo3.o
  • Then I link the objects: 然后我链接对象:
    clang++ -O3 -flto -fprofile-instr-generate obj/foo1.o obj/foo2.o obj/foo3.o -o foobar.out clang ++ -O3 -flto -fprofile-instr-generate obj / foo1.o obj / foo2.o obj / foo3.o -o foobar.out
  • At this point there is the problem: when I try to execute foobar.out with the training instances, the .profraw generated is always empty (and the execution speed is normal, not slower as during the pgo creation), and when I try to compile with the profiles integration (after the merge of the .profraw files), the compiler always gives me the warning "warning: no profile data available for file foo*.cpp" for each foo*.cpp file in my project. 此时存在问题:当我尝试使用训练实例执行foobar.out时,生成的.profraw始终为空(执行速度正常,而不是像创建pgo期间那样慢),当我尝试使用配置文件集成进行编译(在.profraw文件合并之后),编译器总是在我的项目中为每个foo * .cpp文件提供警告“警告:没有可用于文件foo * .cpp的配置文件数据”。

    Could anyone help me trying to understand where is the problem? 任何人都可以帮助我试图了解问题出在哪里? Thank you in advance! 先感谢您!

  • Solved. 解决了。 The problem was that the profiles are generated only in case of a normal exit (return or exit), while in my code the main ended with _exit. 问题是仅在正常退出(返回或退出)的情况​​下生成配置文件,而在我的代码中,主要以_exit结束。

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM