diff options
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBlockPlacement.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index 3149151..5ce4390 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -2506,9 +2506,14 @@ MachineBlockPlacement::collectLoopBlockSet(const MachineLoop &L) { // its frequency and the frequency of the loop block. When it is too small, // don't add it to the loop chain. If there are outer loops, then this block // will be merged into the first outer loop chain for which this block is not - // cold anymore. This needs precise profile data and we only do this when - // profile data is available. - if (F->getFunction().hasProfileData() || ForceLoopColdBlock) { + // cold anymore. + // + // If a block uses static profiling data (e.g. from '__builtin_expect()'), + // then the programmer is explicitly telling us which paths are hot and cold. + // There's no reason for the compiler to believe otherwise, unless + // '-fprofile-use' is specified. + if (F->getFunction().hasProfileData() || ForceLoopColdBlock || + L.hasStaticProfInfo()) { BlockFrequency LoopFreq(0); for (auto LoopPred : L.getHeader()->predecessors()) if (!L.contains(LoopPred)) |