This is an archive of the discontinued LLVM Phabricator instance.

A simple coverage optimization
AbandonedPublic

Authored by george.karpenkov on May 23 2017, 4:09 PM.

Details

Reviewers
kcc
Summary

A simple coverage optimization: if the node has no successors, but multiple predecessors, do not instrument, as predecessors would be instrumented.
Landing this commit would allow us to revert the changes done to tests in https://github.com/llvm-mirror/llvm/commit/1f57bbafaf2dd66752e859d523f941c0b035ec8d

Diff Detail

Event Timeline

kcc edited edge metadata.May 23 2017, 5:52 PM

Hm... I keep not liking this...
A very simple test case will get too many extra edges instrumented if we get rid of PDOMs, even with your extra optimization.
I have such test, but would you like to come up with a test of your own?
If you give up, I'll send mine.

too many extra edges instrumented

weren't the benchmarks showing ~15%?

I have such test

yes please, do send it.

but would you like to come up with a test of your own?

I have a very artificial one, see attached. I am not sure that it counts, and the fact that "too many" is not formally defined makes it more difficult.

kcc added a comment.May 23 2017, 6:15 PM

void foo(int *a, int *b) {

if (*a > 0) {
  b[1] = 0;
  if (*a > 10) {
    b[3] = 0;
  } else {
    b[4] = 0;
  }
} else {
  if (*a < -10) {
    b[5] = 0;
  } else {
    b[6] = 0;
  }
  b[2] = 0;
}

}

@kcc, right, missed that entirely.
What about "is a full post-dominator AND has more than one predecessors" ?
Solves these issues, and ensures that predecessor nodes are not full dominators, yet becomes close to the initial solution in D31266.
Alternatively, I can just take D31266 and add shorter tests.

kcc added a comment.May 23 2017, 6:40 PM

What about "is a full post-dominator AND has more than one predecessors" ?

Yes, I was thinking about this, or, maybe actually
"is a full post-dominator AND has more than one *different* predecessor"
(I don't know if it's possible to have one block to be listed twice in the pred list)

(I don't know if it's possible to have one block to be listed twice in the pred list)

Almost certainly not, from a brief glance quite a lot of code in LLVM codebase relies on getSinglePredecessor check, including dominator tree calculation.

so can I make this change + use your test case to verify that we don't end up with extra instrumentation?

kcc added a comment.May 23 2017, 9:43 PM

so can I make this change + use your test case to verify that we don't end up with extra instrumentation?

Yes, let's try that (except that the test should be .ll, not .cc)

george.karpenkov abandoned this revision.May 24 2017, 10:00 AM

let's drop this in favor of a better optimization.