Open def- opened 6 years ago
Thanks for the pointers, Vedant! I'll take a look.
I'd start by looking at clang's CodeGenFunction::EmitIfStmt. Specifically, when it's successfully able to use ConstantFoldsToSimpleInteger(), you'll want to insert a call to instrprof_increment_step (where the step is determined by the constant folder's result).
Vedant, I guess you're not working on this anymore, but could you please take a look and give some pointers if you see any potential solution?
This is an issue in Chromium as well, so we'll try to fix it eventually: https://bugs.chromium.org/p/chromium/issues/detail?id=845575
This is also an issue with constexprs:
struct Foo { constexpr Foo(int value) : m_value(value) { }
int m_value;
};
constexpr Foo initFoo(int value) { return Foo(value); }
Foo x = initFoo(10);
int main() { std::cout << x.m_value << std::endl; }
I think code that has been covered at compile-time should not be shown as uncovered. Otherwise introducing more constexpr can reduce coverage.
Extended Description
Code regions that can be evaluated at compile-time are shown as uncovered by llvm-cov, for example:
if (true && true) { // second true is uncovered return 0; }
if (argc > 1 && strcmp("&&", "&&) == 0) { // strcmp is uncovered return 0; }
if (argc > 1 && (strcmp)("&&", "&&) == 0) { // strcmp is covered here because it is done at runtime return 0; }
if (argc > 1 && strcmp(argv[1], "&&) == 0) { // strcmp is covered here because it is done at runtime return 0; }
Instead I would expect all of the if line to be covered.