[llvm] r277849 - [AutoFDO] Fix handling of empty profiles
David Callahan via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 5 11:38:19 PDT 2016
Author: david2050
Date: Fri Aug 5 13:38:19 2016
New Revision: 277849
URL: http://llvm.org/viewvc/llvm-project?rev=277849&view=rev
Log:
[AutoFDO] Fix handling of empty profiles
Summary:
If a profile has no samples for a function, then the function "entry count" is set to the value 0. Several places in the code test that if the Function::getEntryCount is defined at all. Here we change to treat a 0 entry count the same as undefined.
In particular, this fixes a problem in getLayoutSuccessorProbThreshold in MachineBlockPlacement.cpp where we use a different and inferior heuristic for laying out basic blocks.
Reviewers: danielcdh, dnovillo
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D23082
Modified:
llvm/trunk/lib/IR/Function.cpp
Modified: llvm/trunk/lib/IR/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=277849&r1=277848&r2=277849&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Function.cpp (original)
+++ llvm/trunk/lib/IR/Function.cpp Fri Aug 5 13:38:19 2016
@@ -1262,7 +1262,10 @@ Optional<uint64_t> Function::getEntryCou
if (MDString *MDS = dyn_cast<MDString>(MD->getOperand(0)))
if (MDS->getString().equals("function_entry_count")) {
ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(1));
- return CI->getValue().getZExtValue();
+ uint64_t Count = CI->getValue().getZExtValue();
+ if (Count == 0)
+ return None;
+ return Count;
}
return None;
}
More information about the llvm-commits
mailing list