This is an archive of the discontinued LLVM Phabricator instance.

[PGO]: Simplify coverage data lowering code
ClosedPublic

Authored by davidxl on Jan 3 2016, 4:01 PM.

Details

Reviewers
vsk
Summary

The names referenced by the coverage data may be associated with functions that are never emitted by Clang. That means those PGO names won't be materialized into the __llvm_prf_names section during instr-prof lowering. To make sure those names are emitted, the lowering pass will need to go through the coverage map global variable and check the referenced names.

The lowering code makes assumption about the layout of the coverage map and function record data which is error prone. Besides, in the near future, when name compression is implemented, the name references won't be available from the coverage data anymore.

In this patch, the referenced names are explicitly recorded in an internal global var and passed to the middle end. This simplifies the lowering code and also make it possible to do name compression. This is part-2 of the patch. Part-1 is http://reviews.llvm.org/D15852

Diff Detail

Event Timeline

davidxl updated this revision to Diff 43867.Jan 3 2016, 4:01 PM
davidxl retitled this revision from to [PGO]: Simplify coverage data lowering code.
davidxl updated this object.
davidxl added a reviewer: vsk.
davidxl added a subscriber: cfe-commits.
davidxl updated this revision to Diff 44127.Jan 6 2016, 9:33 AM

Update patch to reduce overhead: Only record names for unused functions.

vsk edited edge metadata.Jan 7 2016, 9:52 AM

Fwiw the previous version of this patch looked good to me.

In this version 'getCoverageNamesVarName()' has a new meaning. It should probably be renamed (maybe 'getUnusedPGONamesVarName()'), and its comment should be updated.

I see that lowerCoverageData() sets the section information and alignment for names. With this change, it no longer handles records for which addFunctionMappingRecord(isUsed = true). It looks like these names will no longer be materialized into __llvm_prf_names. This doesn't seem right to me. Could you explain why it works? This code is a bit new to me...

lib/CodeGen/CoverageMappingGen.h
75

Nit: Parameter names should be capitalized.

I missed the review comments earlier.

The local var name is fixed. The getCoverageNamesVarName API name will be fixed later.

Regarding to your question: the patch does not not change the behavior of the name handling. For all used functions, their names are handled in regular lowering procedure (getOrCreateRegionCounter) so their names will be skipped by lowerCoverageData actually.

vsk accepted this revision.Aug 1 2016, 6:10 PM
vsk edited edge metadata.

Done in clang/r257092

This revision is now accepted and ready to land.Aug 1 2016, 6:10 PM
vsk closed this revision.Aug 1 2016, 6:10 PM

Closing old review