[PATCH] D13576: Make HeaderLineno a local variable.
Dehao Chen via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 8 16:45:04 PDT 2015
danielcdh created this revision.
danielcdh added reviewers: dnovillo, davidxl.
danielcdh added a subscriber: llvm-commits.
As we are using hierarchical profile, there is no need to keep HeaderLineno a member variable.
http://reviews.llvm.org/D13576
Files:
lib/Transforms/IPO/SampleProfile.cpp
Index: lib/Transforms/IPO/SampleProfile.cpp
===================================================================
--- lib/Transforms/IPO/SampleProfile.cpp
+++ lib/Transforms/IPO/SampleProfile.cpp
@@ -123,10 +123,6 @@
bool propagateThroughEdges(Function &F);
void computeDominanceAndLoopInfo(Function &F);
- /// \brief Line number for the function header. Used to compute absolute
- /// line numbers from the relative line numbers found in the profile.
- unsigned HeaderLineno;
-
/// \brief Map basic blocks to their computed weights.
///
/// The weight of a basic block is defined to be the maximum
@@ -226,14 +222,16 @@
if (!DLoc)
return std::error_code();
- unsigned Lineno = DLoc.getLine();
- if (Lineno < HeaderLineno)
+ const FunctionSamples *FS = findFunctionSamples(Inst);
+ if (!FS)
return std::error_code();
const DILocation *DIL = DLoc;
- const FunctionSamples *FS = findFunctionSamples(Inst);
- if (!FS)
+ unsigned Lineno = DLoc.getLine();
+ unsigned HeaderLineno = DIL->getScope()->getSubprogram()->getLine();
+ if (Lineno < HeaderLineno)
return std::error_code();
+
ErrorOr<unsigned> R =
FS->findSamplesAt(Lineno - HeaderLineno, DIL->getDiscriminator());
if (R)
@@ -837,13 +835,11 @@
bool SampleProfileLoader::emitAnnotations(Function &F) {
bool Changed = false;
- // Initialize invariants used during computation and propagation.
- HeaderLineno = getFunctionLoc(F);
- if (HeaderLineno == 0)
+ if (getFunctionLoc(F) == 0)
return false;
DEBUG(dbgs() << "Line number for the first instruction in " << F.getName()
- << ": " << HeaderLineno << "\n");
+ << ": " << getFunctionLoc(F) << "\n");
Changed |= inlineHotFunctions(F);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13576.36905.patch
Type: text/x-patch
Size: 1755 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151008/0e1ae259/attachment.bin>
More information about the llvm-commits
mailing list