Clang --coverage 和 -fprofile 选项

Tim*_*mmm 6 c++ clang

Clang 有一些与覆盖式分析相关的选项。该命令行参考并没有真正说什么任何人做:

--coverage
-fprofile-arcs
-fprofile-instr-generate
-ftest-coverage
-fcoverage-mapping
Run Code Online (Sandbox Code Playgroud)

按照LLVM-CoV的文档 --coverage能够-fprofile-arcs-ftest-coverage和也许更多。

两个-fprofile-..标志都以某种方式添加检测以记录执行计数,但它们做的事情完全一样吗?如果是这样,为什么两者都有?

llvm-cov 文档说使用-fprofile-arcswithllvm-cov gcov-fprofile-instr-generatellvm-cov show. 为什么?这里发生了什么?

-fcoverage-mapping以及具体-ftest-coverage做什么和做什么?

Tim*_*mmm 10

我开始阅读代码,据我所知:

--coverage启用-ftest-coverage-fprofile-arcs、 并-u__llvm_runtime_variable在 Linux 上添加,或类似的东西。

-fprofile-arcs并且-fprofile-instr-generate 不同的。前者添加-femit-coverage-data,后者添加-fprofile-instrument=clang(其他选项为“none”或“llvm”)。

-ftest-coverage添加-femit-coverage-notes

-fcoverage-mapping添加-fcoverage-mapping

那么选项的作用如下:

ProfileNone,       // Profile instrumentation is turned off.
ProfileClangInstr, // Clang instrumentation to generate execution counts
                   // to use with PGO.
ProfileIRInstr,    // IR level PGO instrumentation in LLVM.
Run Code Online (Sandbox Code Playgroud)

这回答了一些问题,但确实似乎有两个完全不同的分析系统,我不确定其中的区别。