From 145449b1e420787bb99721a429341fa6be3adfb6 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 3 Jul 2022 16:10:23 +0200 Subject: Vendor import of llvm-project main llvmorg-15-init-15358-g53dc0f107877. --- llvm/lib/CodeGen/MachineBlockPlacement.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp') diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index c93ffaabf74c..4cc84f22bdde 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -34,13 +34,13 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/BlockFrequencyInfoImpl.h" #include "llvm/Analysis/ProfileSummaryInfo.h" +#include "llvm/CodeGen/MBFIWrapper.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineBlockFrequencyInfo.h" #include "llvm/CodeGen/MachineBranchProbabilityInfo.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineLoopInfo.h" -#include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachinePostDominators.h" #include "llvm/CodeGen/MachineSizeOpts.h" #include "llvm/CodeGen/TailDuplicator.h" @@ -50,6 +50,7 @@ #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/IR/DebugLoc.h" #include "llvm/IR/Function.h" +#include "llvm/IR/PrintPasses.h" #include "llvm/InitializePasses.h" #include "llvm/Pass.h" #include "llvm/Support/Allocator.h" @@ -200,10 +201,8 @@ static cl::opt TriangleChainCount( cl::init(2), cl::Hidden); -static cl::opt EnableExtTspBlockPlacement( - "enable-ext-tsp-block-placement", cl::Hidden, cl::init(false), - cl::desc("Enable machine block placement based on the ext-tsp model, " - "optimizing I-cache utilization.")); +extern cl::opt EnableExtTspBlockPlacement; +extern cl::opt ApplyExtTspWithoutProfile; namespace llvm { extern cl::opt StaticLikelyProb; @@ -3422,7 +3421,8 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &MF) { } // Apply a post-processing optimizing block placement. - if (MF.size() >= 3 && EnableExtTspBlockPlacement) { + if (MF.size() >= 3 && EnableExtTspBlockPlacement && + (ApplyExtTspWithoutProfile || MF.getFunction().hasProfileData())) { // Find a new placement and modify the layout of the blocks in the function. applyExtTsp(); @@ -3660,6 +3660,9 @@ bool MachineBlockPlacementStats::runOnMachineFunction(MachineFunction &F) { if (std::next(F.begin()) == F.end()) return false; + if (!isFunctionInPrintList(F.getName())) + return false; + MBPI = &getAnalysis(); MBFI = &getAnalysis(); -- cgit v1.2.3