[all-commits] [llvm/llvm-project] 78702d: [InstrProfiling] Ensure data variables are always ...

Alan Phipps via All-commits all-commits at lists.llvm.org
Tue Nov 14 10:38:12 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 78702d3ad9226c789fd75daedc8136e657c2cf74
      https://github.com/llvm/llvm-project/commit/78702d3ad9226c789fd75daedc8136e657c2cf74
  Author: Alan Phipps <a-phipps at ti.com>
  Date:   2023-11-14 (Tue, 14 Nov 2023)

  Changed paths:
    M llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
    M llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
    A llvm/test/Instrumentation/InstrProfiling/inline-data-var-create.ll

  Log Message:
  -----------
  [InstrProfiling] Ensure data variables are always created for inlined functions (#72069)

Fixes a bug introduced by
commit f95b2f1acf11 ("Reland [InstrProf][compiler-rt] Enable MC/DC
Support in LLVM Source-based Code Coverage (1/3)")

The InstrProfiling pass was refactored when introducing support for
MC/DC such that the creation of the data variable was abstracted and
called only once per function from ::run(). Because ::run() only
iterated over functions there were not fully inlined, and because it
only created the data variable for the first intrinsic that it saw, data
variables corresponding to functions fully inlined into other
instrumented callers would end up without a data variable, resulting in
loss of coverage information. This patch does the following:

1.) Move the call of createDataVariable() to getOrCreateRegionCounters()
so that the creation of the data variable will happen indirectly either
from ::new() or during profile intrinsic lowering when it is needed.
This effectively restores the behavior prior to the refactor and ensures
that all data variables are created when needed (and not duplicated).

2.) Process all MC/DC bitmap parameter intrinsics in ::run() prior to
calling getOrCreateRegionCounters(). This ensures bitmap regions are
created for each function including functions that are fully inlined. It
also ensures that the bitmap region is created for each function prior
to the creation of the data variable because it is referenced by the
data variable. Again, duplication is prevented if the same parameter
intrinsic is inlined into multiple functions.

3.) No longer pass the MC/DC intrinsic to createDataVariable(). This
decouples the creation of the data variable from a specific MC/DC
intrinsic. Instead, with #2 above, store the number of bitmap bytes
required in the PerFunctionProfileData in the ProfileDataMap along with
the function's CounterRegion and BitmapRegion variables. This ties the
bitmap information directly to the function to which it belongs, and the
data variable created for that function can reference that.




More information about the All-commits mailing list