[SampleFDO] Make sample profile loader unaware of compact format change.
authorWei Mi <wmi@google.com>
Thu, 6 Sep 2018 22:03:37 +0000 (22:03 +0000)
committerWei Mi <wmi@google.com>
Thu, 6 Sep 2018 22:03:37 +0000 (22:03 +0000)
commit94d44c97bcffbf157b05a45c2f0e56302db9a03c
tree4d7274c699daa90d327ad6709ec3250865917133
parenta0a738b1840fa690a13937774a1a1e994cf58c4f
[SampleFDO] Make sample profile loader unaware of compact format change.

The patch tries to make sample profile loader independent of profile format
change. It moves compact format related code into FunctionSamples and
SampleProfileReader classes, and sample profile loader only has to interact
with those two classes and will be unaware of profile format changes.

The cleanup also contain some fixes to further remove the difference between
compactbinary format and binary format. After the cleanup using different
formats originated from the same profile will generate the same binaries,
which we verified by compiling two large server benchmarks w/wo thinlto.

Differential Revision: https://reviews.llvm.org/D51643

llvm-svn: 341591
llvm/include/llvm/ProfileData/SampleProf.h
llvm/lib/ProfileData/SampleProf.cpp
llvm/lib/ProfileData/SampleProfReader.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/test/Transforms/SampleProfile/Inputs/function_metadata.compact.afdo [new file with mode: 0644]
llvm/test/Transforms/SampleProfile/Inputs/function_metadata.prof
llvm/test/Transforms/SampleProfile/Inputs/indirect-call.compact.afdo [new file with mode: 0644]
llvm/test/Transforms/SampleProfile/function_metadata.ll
llvm/test/Transforms/SampleProfile/indirect-call.ll