[PATCH] D51619: [gcov] Fix branch counters with switch statements

calixte via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 4 04:02:26 PDT 2018


calixte created this revision.
calixte added reviewers: marco-c, davidxl, vsk.
Herald added a subscriber: llvm-commits.

- Fix bug 38821
- Right now, the counters are added in regards of the number of successors for a given BasicBlock: it's good when we've only 1 or 2 successors (at least with BranchInstr). But in the case of a switch statement, the BasicBlock after switch has several predecessors and we need know from which BB we're coming from.
- So the idea is to revert what we're doing: add a PHINode in each block which will select the counter according to the incoming BB.
- They're several pros for doing that:
  - we fix the "switch" bug
  - we remove the function call to "__llvm_gcov_indirect_counter_increment" and the lookup table stuff
  - we replace by PHINodes, so the optimizer will probably makes a better job.


Repository:
  rL LLVM

https://reviews.llvm.org/D51619

Files:
  lib/Transforms/Instrumentation/GCOVProfiling.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51619.163781.patch
Type: text/x-patch
Size: 13281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180904/ba694460/attachment.bin>


More information about the llvm-commits mailing list