[all-commits] [llvm/llvm-project] dbac20: [gcov] Don't split entry block; add a synthetic en...

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed Sep 9 12:25:45 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: dbac20bb6bfbf44dc25ce4c0e1a0ec422fa5cffb
      https://github.com/llvm/llvm-project/commit/dbac20bb6bfbf44dc25ce4c0e1a0ec422fa5cffb
  Author: Fangrui Song <i at maskray.me>
  Date:   2020-09-09 (Wed, 09 Sep 2020)

  Changed paths:
    M llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
    M llvm/test/Transforms/GCOVProfiling/atomic-counter.ll

  Log Message:
  -----------
  [gcov] Don't split entry block; add a synthetic entry block instead

The entry block is split at the first instruction where `shouldKeepInEntry`
returns false. The created basic block has a br jumping to the original entry
block. The new basic block causes the function label line and the other entry
block lines to be covered by different basic blocks, which can affect line
counts with special control flows (fork/exec in the entry block requires
heuristics in llvm-cov gcov to get consistent line counts).

  int main() { // BB0
    return 0;  // BB2 (due to entry block splitting)
  }
  // BB1 is the exit block (since gcov 4.8)

This patch adds a synthetic entry block (like PGOInstrumentation and GCC) and
inserts an edge from the synthetic entry block to the original entry block. We
can thus remove the tricky `shouldKeepInEntry` and entry block splitting. The
number of basic blocks does not change, but the emitted .gcno files will be
smaller because we can save one GCOV_TAG_LINES tag.

  // BB0 is the synthetic entry block with a single edge to BB2
  int main() { // BB2
    return 0;  // BB2
  }
  // BB1 is the exit block (since gcov 4.8)




More information about the All-commits mailing list