aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBlockPlacement.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-07-26 19:03:47 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-07-26 19:04:23 +0000
commit7fa27ce4a07f19b07799a767fc29416f3b625afb (patch)
tree27825c83636c4de341eb09a74f49f5d38a15d165 /llvm/lib/CodeGen/MachineBlockPlacement.cpp
parente3b557809604d036af6e00c60f012c2025b59a5e (diff)
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBlockPlacement.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index 7bbc347a8cf8..912e9ec993e3 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -213,10 +213,9 @@ static cl::opt<bool> RenumberBlocksBeforeView(
"into a dot graph. Only used when a function is being printed."),
cl::init(false), cl::Hidden);
+namespace llvm {
extern cl::opt<bool> EnableExtTspBlockPlacement;
extern cl::opt<bool> ApplyExtTspWithoutProfile;
-
-namespace llvm {
extern cl::opt<unsigned> StaticLikelyProb;
extern cl::opt<unsigned> ProfileLikelyProb;
@@ -354,15 +353,15 @@ class MachineBlockPlacement : public MachineFunctionPass {
/// Pair struct containing basic block and taildup profitability
struct BlockAndTailDupResult {
- MachineBasicBlock *BB;
+ MachineBasicBlock *BB = nullptr;
bool ShouldTailDup;
};
/// Triple struct containing edge weight and the edge.
struct WeightedEdge {
BlockFrequency Weight;
- MachineBasicBlock *Src;
- MachineBasicBlock *Dest;
+ MachineBasicBlock *Src = nullptr;
+ MachineBasicBlock *Dest = nullptr;
};
/// work lists of blocks that are ready to be laid out
@@ -373,32 +372,32 @@ class MachineBlockPlacement : public MachineFunctionPass {
DenseMap<const MachineBasicBlock *, BlockAndTailDupResult> ComputedEdges;
/// Machine Function
- MachineFunction *F;
+ MachineFunction *F = nullptr;
/// A handle to the branch probability pass.
- const MachineBranchProbabilityInfo *MBPI;
+ const MachineBranchProbabilityInfo *MBPI = nullptr;
/// A handle to the function-wide block frequency pass.
std::unique_ptr<MBFIWrapper> MBFI;
/// A handle to the loop info.
- MachineLoopInfo *MLI;
+ MachineLoopInfo *MLI = nullptr;
/// Preferred loop exit.
/// Member variable for convenience. It may be removed by duplication deep
/// in the call stack.
- MachineBasicBlock *PreferredLoopExit;
+ MachineBasicBlock *PreferredLoopExit = nullptr;
/// A handle to the target's instruction info.
- const TargetInstrInfo *TII;
+ const TargetInstrInfo *TII = nullptr;
/// A handle to the target's lowering info.
- const TargetLoweringBase *TLI;
+ const TargetLoweringBase *TLI = nullptr;
/// A handle to the post dominator tree.
- MachinePostDominatorTree *MPDT;
+ MachinePostDominatorTree *MPDT = nullptr;
- ProfileSummaryInfo *PSI;
+ ProfileSummaryInfo *PSI = nullptr;
/// Duplicator used to duplicate tails during placement.
///
@@ -412,7 +411,7 @@ class MachineBlockPlacement : public MachineFunctionPass {
/// True: use block profile count to compute tail duplication cost.
/// False: use block frequency to compute tail duplication cost.
- bool UseProfileCount;
+ bool UseProfileCount = false;
/// Allocator and owner of BlockChain structures.
///
@@ -1160,7 +1159,7 @@ bool MachineBlockPlacement::canTailDuplicateUnplacedPreds(
// tail-duplicated into.
// Skip any blocks that are already placed or not in this loop.
if (Pred == BB || (BlockFilter && !BlockFilter->count(Pred))
- || BlockToChain[Pred] == &Chain)
+ || (BlockToChain[Pred] == &Chain && !Succ->succ_empty()))
continue;
if (!TailDup.canTailDuplicate(Succ, Pred)) {
if (Successors.size() > 1 && hasSameSuccessors(*Pred, Successors))
@@ -2018,7 +2017,7 @@ MachineBlockPlacement::FallThroughGains(
for (MachineBasicBlock *Succ : BestPred->successors()) {
if ((Succ == NewTop) || (Succ == BestPred) || !LoopBlockSet.count(Succ))
continue;
- if (ComputedEdges.find(Succ) != ComputedEdges.end())
+ if (ComputedEdges.contains(Succ))
continue;
BlockChain *SuccChain = BlockToChain[Succ];
if ((SuccChain && (Succ != *SuccChain->begin())) ||