This is an archive of the discontinued LLVM Phabricator instance.

Use ProfileData/InstrProfData.inc template file to define PGO runtime types
ClosedPublic

Authored by davidxl on Oct 16 2015, 8:49 PM.

Details

Summary

In r250574, a template file is introduced to be a centralized place to define core PGO data structures that are shared between runtime, reader, and writer. In this patch, the file is used to replace 'hard' coded definitions so that they can always be in sync. Changes in the future will only (mostly) need to touch one file only (the template file).

A couple of notes:

  1. clang FE change to use the the template file (will be in a different patch)
  2. find a way to share header files between LLVM compiler and compiler_rt.
  3. more portable way to specify packed struct.

Diff Detail

Repository
rL LLVM

Event Timeline

davidxl updated this revision to Diff 37671.Oct 16 2015, 8:49 PM
davidxl retitled this revision from to Use ProfileData/InstrProfData.inc template file to define PGO runtime types.
davidxl updated this object.
davidxl added a reviewer: bogner.
davidxl added a subscriber: llvm-commits.
davidxl updated this revision to Diff 38973.Nov 2 2015, 1:01 PM

Update patch and ping ..

vsk added a subscriber: vsk.Nov 3 2015, 6:48 PM

Thanks for the cleanup. Some inline comments --

include/llvm/ProfileData/InstrProf.h
434 ↗(On Diff #38973)

In 'InstrProfData.inc', the macro parameters names are a bit more descriptive. Could you use the same names here?

458 ↗(On Diff #38973)

Same nit as above.

lib/ProfileData/CoverageMappingReader.cpp
369 ↗(On Diff #38973)

Could you make the l.h.s auto *CFR?

370 ↗(On Diff #38973)

I notice that the old code used unaligned accesses when unpacking FunBuf.

I think having an assertion here for the assumed alignment would make for good future-proofing. Could we assert that CFR->FuncHash is 8-byte aligned?

davidxl marked 3 inline comments as done.Nov 3 2015, 9:17 PM
davidxl added inline comments.
lib/ProfileData/CoverageMappingReader.cpp
370 ↗(On Diff #38973)

Actually on 32bit target, CFR->FuncHash is not 8 byte aligned. To support reading coverage data produced by 32bit target on a 64bit host, the CovMapFunctionRecord struct (instantiated with 32 bit IntPtrT for 32bit target) needs to be declared with attribute((packed)). The attribute does not affect this struct's native layout.

davidxl updated this revision to Diff 39164.Nov 3 2015, 9:19 PM

Updated patch according to Vedant's comment.

vsk added a comment.Nov 3 2015, 9:26 PM

Thanks for clarifying, this lgtm.

This revision was automatically updated to reflect the committed changes.