Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit c6b24c2

Browse files
author
Diego Novillo
committed
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
1 parent 086ed79 commit c6b24c2

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/Transforms/IPO/SampleProfile.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,11 @@ SampleProfileLoader::getInstWeight(const Instruction &Inst) const {
344344
if (FirstMark) {
345345
const Function *F = Inst.getParent()->getParent();
346346
LLVMContext &Ctx = F->getContext();
347-
emitOptimizationRemark(Ctx, DEBUG_TYPE, *F, DLoc,
348-
Twine("Applied ") + Twine(*R) +
349-
" samples from profile");
347+
emitOptimizationRemark(
348+
Ctx, DEBUG_TYPE, *F, DLoc,
349+
Twine("Applied ") + Twine(*R) + " samples from profile (offset: " +
350+
Twine(LineOffset) +
351+
((Discriminator) ? Twine(".") + Twine(Discriminator) : "") + ")");
350352
}
351353
DEBUG(dbgs() << " " << Lineno << "." << DIL->getDiscriminator() << ":"
352354
<< Inst << " (line offset: " << Lineno - HeaderLineno << "."

test/Transforms/SampleProfile/inline-coverage.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
; 12 }
1717
;
1818
; CHECK: remark: coverage.cc:10:12: inlined hot callee '_Z3fool' with 172746 samples into 'main'
19-
; CHECK: remark: coverage.cc:9:19: Applied 23478 samples from profile
20-
; CHECK: remark: coverage.cc:10:16: Applied 23478 samples from profile
21-
; CHECK: remark: coverage.cc:4:10: Applied 31878 samples from profile
22-
; CHECK: remark: coverage.cc:11:10: Applied 0 samples from profile
19+
; CHECK: remark: coverage.cc:9:19: Applied 23478 samples from profile (offset: 2.1)
20+
; CHECK: remark: coverage.cc:10:16: Applied 23478 samples from profile (offset: 3)
21+
; CHECK: remark: coverage.cc:4:10: Applied 31878 samples from profile (offset: 1)
22+
; CHECK: remark: coverage.cc:11:10: Applied 0 samples from profile (offset: 4)
2323
; CHECK: remark: coverage.cc:10:16: most popular destination for conditional branches at coverage.cc:9:3
2424
;
2525
; There is one sample record with 0 samples at offset 4 in main() that we never

0 commit comments

Comments
 (0)