summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDehao Chen <dehao@google.com>2015-10-09 16:50:16 +0000
committerDehao Chen <dehao@google.com>2015-10-09 16:50:16 +0000
commit41dc5a6e862702f270ae5d804654ab1484e1535e (patch)
treede65e2290235be7caffb49940a2dda9387b87c11 /llvm/lib
parent848055ad16e760bf1dea26ca7707bbc0b14c4db8 (diff)
downloadbcm5719-llvm-41dc5a6e862702f270ae5d804654ab1484e1535e.tar.gz
bcm5719-llvm-41dc5a6e862702f270ae5d804654ab1484e1535e.zip
Make HeaderLineno a local variable.
http://reviews.llvm.org/D13576 As we are using hierarchical profile, there is no need to keep HeaderLineno a member variable. This is because each level of the inline stack will have its own header lineno. One should use the head lineno of its own inline stack level instead of the actual symbol. llvm-svn: 249848
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/SampleProfile.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index a4ce65fd4ab..cb4dad2f7eb 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -123,10 +123,6 @@ protected:
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 @@ SampleProfileLoader::getInstWeight(const Instruction &Inst) const {
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 @@ void SampleProfileLoader::computeDominanceAndLoopInfo(Function &F) {
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);
OpenPOWER on IntegriCloud