SamplePGO - Add line offset and discriminator information to sample reports.
authorDiego Novillo <dnovillo@google.com>
Fri, 20 Nov 2015 15:39:42 +0000 (15:39 +0000)
committerDiego Novillo <dnovillo@google.com>
Fri, 20 Nov 2015 15:39:42 +0000 (15:39 +0000)
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

lib/Transforms/IPO/SampleProfile.cpp
test/Transforms/SampleProfile/inline-coverage.ll

index 5979f022bc6b2d21f2571d1cc3987dda80c22d75..df8c8a0f7c4ea8bc62a57ebed66e96af2553b6ab 100644 (file)
@@ -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 << "."
index 4f87b1661a6784fc148f86d182077dc0f62363c6..0b97b560a4f31f301270bd5395f3e0e382145f4a 100644 (file)
 ;    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