[PATCH] Support using sample profiles with partial debug info.
David Blaikie
dblaikie at gmail.com
Tue Oct 21 12:38:56 PDT 2014
================
Comment at: lib/Transforms/Scalar/SampleProfile.cpp:662
@@ +661,3 @@
+ // leading back to \p F.
+ for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) {
+ BasicBlock *B = I;
----------------
Please use range-based-for loops.
================
Comment at: lib/Transforms/Scalar/SampleProfile.cpp:671
@@ +670,3 @@
+ if (Subprogram.describes(&F))
+ return Subprogram.getLineNumber();
+ }
----------------
If you find an instruction with DebugLoc, you don't need to keep searching - no matter what its subprogram node is.
This is what I tried to describe with the pseudocode I mentioned on IRC the other day.
for (basic blocks)
for (instructions)
if (debugloc.isvalid)
if (getsubprogram(debugloc).describes(F))
return subprogram.getLineNumber()
else
/* break out of all the loops & consider this a failure */
(maybe wrap all this in a function so you can more easily early-exit when you reach that situation)
Here's the invariant that I believe now holds:
If a function has debug info, the scope chain of all instructions in that function will lead to the function and nothing else.
So once you find one instruction with a debug loc, you don't need to examine any others - if it leads to this function, you're done, if it doesn't then this function doesn't have debug info.
================
Comment at: test/Transforms/SampleProfile/loc-tracking-only.ll:3
@@ +2,3 @@
+
+; This test is identical to calls.ll but it is missing the llvm.dbg.cu
+; annotation. This emulates the effect of the user having only used
----------------
Worth updating calls.ll itself instead of adding a new test? If you don't depend on the llvm.dbg.cu at all, it doesn't seem worthwhile to have two different tests, one with it and one without it.
http://reviews.llvm.org/D5887
More information about the llvm-commits
mailing list