From: Diego Novillo Date: Fri, 20 Nov 2015 15:39:42 +0000 (+0000) Subject: SamplePGO - Add line offset and discriminator information to sample reports. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;ds=sidebyside;h=c6b24c2806aa07c6b0dcba478314d5c5a24ced34;p=oota-llvm.git SamplePGO - Add line offset and discriminator information to sample reports. While debugging some sampling coverage problems, I found this useful: When applying samples from a profile, it helps to also know what line offset and discriminator the sample belongs to. This makes it easy to correlate against the input profile. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253670 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/IPO/SampleProfile.cpp b/lib/Transforms/IPO/SampleProfile.cpp index 5979f022bc6..df8c8a0f7c4 100644 --- a/lib/Transforms/IPO/SampleProfile.cpp +++ b/lib/Transforms/IPO/SampleProfile.cpp @@ -344,9 +344,11 @@ SampleProfileLoader::getInstWeight(const Instruction &Inst) const { if (FirstMark) { const Function *F = Inst.getParent()->getParent(); LLVMContext &Ctx = F->getContext(); - emitOptimizationRemark(Ctx, DEBUG_TYPE, *F, DLoc, - Twine("Applied ") + Twine(*R) + - " samples from profile"); + emitOptimizationRemark( + Ctx, DEBUG_TYPE, *F, DLoc, + Twine("Applied ") + Twine(*R) + " samples from profile (offset: " + + Twine(LineOffset) + + ((Discriminator) ? Twine(".") + Twine(Discriminator) : "") + ")"); } DEBUG(dbgs() << " " << Lineno << "." << DIL->getDiscriminator() << ":" << Inst << " (line offset: " << Lineno - HeaderLineno << "." diff --git a/test/Transforms/SampleProfile/inline-coverage.ll b/test/Transforms/SampleProfile/inline-coverage.ll index 4f87b1661a6..0b97b560a4f 100644 --- a/test/Transforms/SampleProfile/inline-coverage.ll +++ b/test/Transforms/SampleProfile/inline-coverage.ll @@ -16,10 +16,10 @@ ; 12 } ; ; CHECK: remark: coverage.cc:10:12: inlined hot callee '_Z3fool' with 172746 samples into 'main' -; CHECK: remark: coverage.cc:9:19: Applied 23478 samples from profile -; CHECK: remark: coverage.cc:10:16: Applied 23478 samples from profile -; CHECK: remark: coverage.cc:4:10: Applied 31878 samples from profile -; CHECK: remark: coverage.cc:11:10: Applied 0 samples from profile +; CHECK: remark: coverage.cc:9:19: Applied 23478 samples from profile (offset: 2.1) +; CHECK: remark: coverage.cc:10:16: Applied 23478 samples from profile (offset: 3) +; CHECK: remark: coverage.cc:4:10: Applied 31878 samples from profile (offset: 1) +; CHECK: remark: coverage.cc:11:10: Applied 0 samples from profile (offset: 4) ; CHECK: remark: coverage.cc:10:16: most popular destination for conditional branches at coverage.cc:9:3 ; ; There is one sample record with 0 samples at offset 4 in main() that we never