private:
bool shouldOutlineFrom(const Function &F) const;
- Function *outlineColdBlocks(Function &F,
- const DenseSetBB &ColdBlock,
- DominatorTree *DT, PostDomTree *PDT);
+ const Function *outlineColdBlocks(Function &F, const DenseSetBB &ColdBlock,
+ DominatorTree *DT, PostDomTree *PDT);
Function *extractColdRegion(const SmallVectorImpl<BasicBlock *> &Region,
DominatorTree *DT, BlockFrequencyInfo *BFI,
OptimizationRemarkEmitter &ORE);
} // end anonymous namespace
// Returns false if the function should not be considered for hot-cold split
-// optimization. Already outlined functions have coldcc so no need to check
-// for them here.
+// optimization.
bool HotColdSplitting::shouldOutlineFrom(const Function &F) const {
+ // Do not try to outline again from an already outlined cold function.
+ if (OutlinedFunctions.count(&F))
+ return false;
+
if (F.size() <= 2)
return false;
CS.setCallingConv(CallingConv::Cold);
}
CI->setIsNoInline();
- LLVM_DEBUG(llvm::dbgs() << "Outlined Region at block: " << Region.front());
+ LLVM_DEBUG(llvm::dbgs() << "Outlined Region: " << *OutF);
return OutF;
}
}
// Return the function created after outlining, nullptr otherwise.
-Function *HotColdSplitting::outlineColdBlocks(Function &F,
- const DenseSetBB &HotBlocks,
- DominatorTree *DT,
- PostDomTree *PDT) {
+const Function *HotColdSplitting::outlineColdBlocks(Function &F,
+ const DenseSetBB &HotBlocks,
+ DominatorTree *DT,
+ PostDomTree *PDT) {
auto BFI = GetBFI(F);
auto &ORE = (*GetORE)(F);
// Walking the dominator tree allows us to find the largest
if (PSI->isColdBB(BB, BFI) || !HotBlocks.count(BB)) {
SmallVector<BasicBlock *, 4> ValidColdRegion, Region;
BasicBlock *Exit = (*PDT)[BB]->getIDom()->getBlock();
- // We might need a virtual exit which post-dominates all basic blocks.
- if (!Exit)
- continue;
BasicBlock *ExitColdRegion = nullptr;
+
// Estimated cold region between a BB and its dom-frontier.
- while (isSingleEntrySingleExit(BB, Exit, DT, PDT, Region) &&
+ while (Exit && isSingleEntrySingleExit(BB, Exit, DT, PDT, Region) &&
isOutlineCandidate(Region, Exit)) {
ExitColdRegion = Exit;
ValidColdRegion = Region;
continue;
++NumColdSESEFound;
+ ValidColdRegion.push_back(ExitColdRegion);
// Candidate for outlining. FIXME: Continue outlining.
return extractColdRegion(ValidColdRegion, DT, BFI, ORE);
}
if (EnableStaticAnalyis) // Static analysis of cold blocks.
HotBlocks = getHotBlocks(F);
- auto Outlined = outlineColdBlocks(F, HotBlocks, &DT, &PDT);
+ const Function *Outlined = outlineColdBlocks(F, HotBlocks, &DT, &PDT);
if (Outlined)
OutlinedFunctions.insert(Outlined);
}
; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
-source_filename = "bugpoint-output-054409e.bc"
-target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-apple-macosx10.13.0"
-
-declare i32 @__gxx_personality_v0(...)
; Outlined function is called from a basic block named codeRepl
; CHECK: codeRepl:
; CHECK-NEXT: call void @foo
-; Function Attrs: ssp uwtable
-define hidden void @foo() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+define void @foo() {
entry:
br i1 undef, label %if.then, label %if.end
return: ; preds = %cleanup40
ret void
}
-
-