73#define DEBUG_TYPE "code-extractor"
81 cl::desc(
"Aggregate arguments to code-extracted functions"));
86 bool AllowVarArgs,
bool AllowAlloca) {
99 while (!ToVisit.
empty()) {
101 if (!Visited.
insert(Curr).second)
103 if (isa<BlockAddress const>(Curr))
106 if (isa<Instruction>(Curr) && cast<Instruction>(Curr)->
getParent() != &BB)
109 for (
auto const &U : Curr->
operands()) {
110 if (
auto *UU = dyn_cast<User>(U))
118 if (isa<AllocaInst>(
I)) {
124 if (
const auto *
II = dyn_cast<InvokeInst>(
I)) {
127 if (
auto *UBB =
II->getUnwindDest())
128 if (!Result.count(UBB))
135 if (
const auto *CSI = dyn_cast<CatchSwitchInst>(
I)) {
136 if (
auto *UBB = CSI->getUnwindDest())
137 if (!Result.count(UBB))
139 for (
const auto *HBB : CSI->handlers())
140 if (!Result.count(
const_cast<BasicBlock*
>(HBB)))
147 if (
const auto *CPI = dyn_cast<CatchPadInst>(
I)) {
148 for (
const auto *U : CPI->users())
149 if (
const auto *CRI = dyn_cast<CatchReturnInst>(U))
150 if (!Result.count(
const_cast<BasicBlock*
>(CRI->getParent())))
158 if (
const auto *CPI = dyn_cast<CleanupPadInst>(
I)) {
159 for (
const auto *U : CPI->users())
160 if (
const auto *CRI = dyn_cast<CleanupReturnInst>(U))
161 if (!Result.count(
const_cast<BasicBlock*
>(CRI->getParent())))
165 if (
const auto *CRI = dyn_cast<CleanupReturnInst>(
I)) {
166 if (
auto *UBB = CRI->getUnwindDest())
167 if (!Result.count(UBB))
172 if (
const CallInst *CI = dyn_cast<CallInst>(
I)) {
173 if (
const Function *
F = CI->getCalledFunction()) {
174 auto IID =
F->getIntrinsicID();
175 if (IID == Intrinsic::vastart) {
184 if (IID == Intrinsic::eh_typeid_for)
196 bool AllowVarArgs,
bool AllowAlloca) {
197 assert(!BBs.
empty() &&
"The set of blocks to extract must be non-empty");
207 if (!Result.insert(BB))
211 LLVM_DEBUG(
dbgs() <<
"Region front block: " << Result.front()->getName()
214 for (
auto *BB : Result) {
219 if (BB == Result.front()) {
221 LLVM_DEBUG(
dbgs() <<
"The first block cannot be an unwind block\n");
230 if (!Result.count(PBB)) {
231 LLVM_DEBUG(
dbgs() <<
"No blocks in this region may have entries from "
232 "outside the region except for the first block!\n"
233 <<
"Problematic source BB: " << BB->getName() <<
"\n"
234 <<
"Problematic destination BB: " << PBB->getName()
246 bool AllowVarArgs,
bool AllowAlloca,
247 BasicBlock *AllocationBlock, std::string Suffix,
248 bool ArgsInZeroAddressSpace)
250 BPI(BPI), AC(AC), AllocationBlock(AllocationBlock),
251 AllowVarArgs(AllowVarArgs),
253 Suffix(Suffix), ArgsInZeroAddressSpace(ArgsInZeroAddressSpace) {}
259 if (
Blocks.count(
I->getParent()))
268 if (isa<Argument>(V))
return true;
270 if (!
Blocks.count(
I->getParent()))
282 if (!CommonExitBlock) {
283 CommonExitBlock = Succ;
286 if (CommonExitBlock != Succ)
295 return CommonExitBlock;
301 if (
auto *AI = dyn_cast<AllocaInst>(&
II))
302 Allocas.push_back(AI);
304 findSideEffectInfoForBlock(BB);
308void CodeExtractorAnalysisCache::findSideEffectInfoForBlock(
BasicBlock &BB) {
310 unsigned Opcode =
II.getOpcode();
311 Value *MemAddr =
nullptr;
313 case Instruction::Store:
314 case Instruction::Load: {
315 if (Opcode == Instruction::Store) {
317 MemAddr = SI->getPointerOperand();
323 if (isa<Constant>(MemAddr))
326 if (!isa<AllocaInst>(
Base)) {
327 SideEffectingBlocks.insert(&BB);
330 BaseMemAddrs[&BB].insert(
Base);
338 SideEffectingBlocks.insert(&BB);
342 if (
II.mayHaveSideEffects()) {
343 SideEffectingBlocks.insert(&BB);
353 if (SideEffectingBlocks.count(&BB))
355 auto It = BaseMemAddrs.find(&BB);
356 if (It != BaseMemAddrs.end())
357 return It->second.count(
Addr);
363 AllocaInst *AI = cast<AllocaInst>(
Addr->stripInBoundsConstantOffsets());
366 if (Blocks.count(&BB))
376 BasicBlock *SinglePredFromOutlineRegion =
nullptr;
377 assert(!Blocks.count(CommonExitBlock) &&
378 "Expect a block outside the region!");
380 if (!Blocks.count(Pred))
382 if (!SinglePredFromOutlineRegion) {
383 SinglePredFromOutlineRegion = Pred;
384 }
else if (SinglePredFromOutlineRegion != Pred) {
385 SinglePredFromOutlineRegion =
nullptr;
390 if (SinglePredFromOutlineRegion)
391 return SinglePredFromOutlineRegion;
397 while (
I != BB->
end()) {
398 PHINode *Phi = dyn_cast<PHINode>(
I);
410 assert(!getFirstPHI(CommonExitBlock) &&
"Phi not expected");
418 if (Blocks.count(Pred))
423 Blocks.insert(CommonExitBlock);
424 return CommonExitBlock;
431CodeExtractor::LifetimeMarkerInfo
435 LifetimeMarkerInfo
Info;
445 Info.LifeStart = IntrInst;
451 Info.LifeEnd = IntrInst;
456 if (isa<DbgInfoIntrinsic>(IntrInst))
464 if (!
Info.LifeStart || !
Info.LifeEnd)
470 if ((
Info.SinkLifeStart ||
Info.HoistLifeEnd) &&
475 if (
Info.HoistLifeEnd && !ExitBlock)
487 auto moveOrIgnoreLifetimeMarkers =
488 [&](
const LifetimeMarkerInfo &LMI) ->
bool {
491 if (LMI.SinkLifeStart) {
494 SinkCands.
insert(LMI.LifeStart);
496 if (LMI.HoistLifeEnd) {
497 LLVM_DEBUG(
dbgs() <<
"Hoisting lifetime.end: " << *LMI.LifeEnd <<
"\n");
498 HoistCands.
insert(LMI.LifeEnd);
507 if (Blocks.count(BB))
516 LifetimeMarkerInfo MarkerInfo = getLifetimeMarkers(CEAC, AI, ExitBlock);
517 bool Moved = moveOrIgnoreLifetimeMarkers(MarkerInfo);
529 for (
User *U : AI->users()) {
533 if (U->stripInBoundsConstantOffsets() != AI)
537 for (
User *BU : Bitcast->users()) {
549 << *Bitcast <<
" in out-of-region lifetime marker "
550 << *IntrInst <<
"\n");
551 LifetimeBitcastUsers.
push_back(IntrInst);
561 I->replaceUsesOfWith(
I->getOperand(1), CastI);
567 for (
User *U : AI->users()) {
568 if (U->stripInBoundsConstantOffsets() == AI) {
570 LifetimeMarkerInfo LMI = getLifetimeMarkers(CEAC, Bitcast, ExitBlock);
586 if (Bitcasts.
empty())
589 LLVM_DEBUG(
dbgs() <<
"Sinking alloca (via bitcast): " << *AI <<
"\n");
591 for (
unsigned I = 0, E = Bitcasts.
size();
I != E; ++
I) {
593 const LifetimeMarkerInfo &LMI = BitcastLifetimeInfo[
I];
595 "Unsafe to sink bitcast without lifetime markers");
596 moveOrIgnoreLifetimeMarkers(LMI);
598 LLVM_DEBUG(
dbgs() <<
"Sinking bitcast-of-alloca: " << *BitcastAddr
600 SinkCands.
insert(BitcastAddr);
614 if (AllowVarArgs &&
F->getFunctionType()->isVarArg()) {
615 auto containsVarArgIntrinsic = [](
const Instruction &
I) {
616 if (
const CallInst *CI = dyn_cast<CallInst>(&
I))
617 if (
const Function *Callee = CI->getCalledFunction())
618 return Callee->getIntrinsicID() == Intrinsic::vastart ||
619 Callee->getIntrinsicID() == Intrinsic::vaend;
623 for (
auto &BB : *
F) {
624 if (Blocks.count(&BB))
638 bool IsSave =
II->getIntrinsicID() == Intrinsic::stacksave;
639 bool IsRestore =
II->getIntrinsicID() == Intrinsic::stackrestore;
640 if (IsSave &&
any_of(
II->users(), [&Blks = this->Blocks](
User *U) {
641 return !definedInRegion(Blks, U);
653 bool CollectGlobalInputs)
const {
658 for (
auto &OI :
II.operands()) {
660 if (!SinkCands.
count(V) &&
662 (CollectGlobalInputs && llvm::isa<llvm::GlobalVariable>(V))))
666 for (
User *U :
II.users())
678void CodeExtractor::severSplitPHINodesOfEntry(
BasicBlock *&Header) {
679 unsigned NumPredsFromRegion = 0;
680 unsigned NumPredsOutsideRegion = 0;
682 if (Header != &Header->getParent()->getEntryBlock()) {
683 PHINode *PN = dyn_cast<PHINode>(Header->begin());
691 ++NumPredsFromRegion;
693 ++NumPredsOutsideRegion;
697 if (NumPredsOutsideRegion <= 1)
return;
709 Blocks.remove(OldPred);
710 Blocks.insert(NewBB);
715 if (NumPredsFromRegion) {
728 for (AfterPHIs = OldPred->
begin(); isa<PHINode>(AfterPHIs); ++AfterPHIs) {
729 PHINode *PN = cast<PHINode>(AfterPHIs);
755void CodeExtractor::severSplitPHINodesOfExits() {
756 for (
BasicBlock *ExitBB : ExtractedFuncRetVals) {
759 for (
PHINode &PN : ExitBB->phis()) {
769 if (IncomingVals.
size() <= 1)
776 ExitBB->getName() +
".split",
777 ExitBB->getParent(), ExitBB);
781 if (Blocks.count(PredBB))
782 PredBB->getTerminator()->replaceUsesOfWith(ExitBB, NewBB);
784 Blocks.insert(NewBB);
791 for (
unsigned i : IncomingVals)
793 for (
unsigned i :
reverse(IncomingVals))
800void CodeExtractor::splitReturnBlocks() {
804 Block->splitBasicBlock(RI->getIterator(),
Block->getName() +
".ret");
820Function *CodeExtractor::constructFunctionDeclaration(
821 const ValueSet &inputs,
const ValueSet &outputs,
BlockFrequency EntryFreq,
830 std::vector<Type *> ParamTy;
831 std::vector<Type *> AggParamTy;
837 if (AggregateArgs && !ExcludeArgsFromAggregate.
contains(
value)) {
838 AggParamTy.push_back(
value->getType());
839 StructValues.insert(
value);
841 ParamTy.push_back(
value->getType());
845 for (
Value *output : outputs) {
847 if (AggregateArgs && !ExcludeArgsFromAggregate.
contains(output)) {
848 AggParamTy.push_back(output->getType());
849 StructValues.insert(output);
856 (ParamTy.size() + AggParamTy.size()) ==
857 (inputs.size() + outputs.size()) &&
858 "Number of scalar and aggregate params does not match inputs, outputs");
859 assert((StructValues.empty() || AggregateArgs) &&
860 "Expeced StructValues only with AggregateArgs set");
863 if (!AggParamTy.empty()) {
866 StructTy, ArgsInZeroAddressSpace ? 0 :
DL.getAllocaAddrSpace()));
871 dbgs() <<
"Function type: " << *
RetTy <<
" f(";
872 for (
Type *i : ParamTy)
873 dbgs() << *i <<
", ";
897 if (Attr.isStringAttribute()) {
898 if (Attr.getKindAsString() ==
"thunk")
901 switch (Attr.getKindAsEnum()) {
904 case Attribute::AllocSize:
905 case Attribute::Builtin:
906 case Attribute::Convergent:
907 case Attribute::JumpTable:
908 case Attribute::Naked:
909 case Attribute::NoBuiltin:
910 case Attribute::NoMerge:
911 case Attribute::NoReturn:
912 case Attribute::NoSync:
913 case Attribute::ReturnsTwice:
914 case Attribute::Speculatable:
915 case Attribute::StackAlignment:
916 case Attribute::WillReturn:
917 case Attribute::AllocKind:
918 case Attribute::PresplitCoroutine:
919 case Attribute::Memory:
920 case Attribute::NoFPClass:
921 case Attribute::CoroDestroyOnlyWhenComplete:
922 case Attribute::CoroElideSafe:
923 case Attribute::NoDivergenceSource:
926 case Attribute::AlwaysInline:
927 case Attribute::Cold:
928 case Attribute::DisableSanitizerInstrumentation:
929 case Attribute::FnRetThunkExtern:
931 case Attribute::HybridPatchable:
932 case Attribute::NoRecurse:
933 case Attribute::InlineHint:
934 case Attribute::MinSize:
935 case Attribute::NoCallback:
936 case Attribute::NoDuplicate:
937 case Attribute::NoFree:
938 case Attribute::NoImplicitFloat:
939 case Attribute::NoInline:
940 case Attribute::NonLazyBind:
941 case Attribute::NoRedZone:
942 case Attribute::NoUnwind:
943 case Attribute::NoSanitizeBounds:
944 case Attribute::NoSanitizeCoverage:
945 case Attribute::NullPointerIsValid:
946 case Attribute::OptimizeForDebugging:
947 case Attribute::OptForFuzzing:
948 case Attribute::OptimizeNone:
949 case Attribute::OptimizeForSize:
950 case Attribute::SafeStack:
951 case Attribute::ShadowCallStack:
952 case Attribute::SanitizeAddress:
953 case Attribute::SanitizeMemory:
954 case Attribute::SanitizeNumericalStability:
955 case Attribute::SanitizeThread:
956 case Attribute::SanitizeType:
957 case Attribute::SanitizeHWAddress:
958 case Attribute::SanitizeMemTag:
959 case Attribute::SanitizeRealtime:
960 case Attribute::SanitizeRealtimeBlocking:
961 case Attribute::SpeculativeLoadHardening:
962 case Attribute::StackProtect:
963 case Attribute::StackProtectReq:
964 case Attribute::StackProtectStrong:
965 case Attribute::StrictFP:
966 case Attribute::UWTable:
967 case Attribute::VScaleRange:
968 case Attribute::NoCfCheck:
969 case Attribute::MustProgress:
970 case Attribute::NoProfile:
971 case Attribute::SkipProfile:
974 case Attribute::Alignment:
975 case Attribute::AllocatedPointer:
976 case Attribute::AllocAlign:
977 case Attribute::ByVal:
978 case Attribute::Dereferenceable:
979 case Attribute::DereferenceableOrNull:
980 case Attribute::ElementType:
981 case Attribute::InAlloca:
982 case Attribute::InReg:
983 case Attribute::Nest:
984 case Attribute::NoAlias:
985 case Attribute::NoCapture:
986 case Attribute::NoUndef:
987 case Attribute::NonNull:
988 case Attribute::Preallocated:
989 case Attribute::ReadNone:
990 case Attribute::ReadOnly:
991 case Attribute::Returned:
992 case Attribute::SExt:
993 case Attribute::StructRet:
994 case Attribute::SwiftError:
995 case Attribute::SwiftSelf:
996 case Attribute::SwiftAsync:
997 case Attribute::ZExt:
998 case Attribute::ImmArg:
999 case Attribute::ByRef:
1000 case Attribute::WriteOnly:
1001 case Attribute::Writable:
1002 case Attribute::DeadOnUnwind:
1003 case Attribute::Range:
1004 case Attribute::Initializes:
1005 case Attribute::NoExt:
1023 for (
Value *input : inputs) {
1024 if (StructValues.contains(input))
1027 ScalarAI->
setName(input->getName());
1028 if (input->isSwiftError())
1030 Attribute::SwiftError);
1033 for (
Value *output : outputs) {
1034 if (StructValues.contains(output))
1037 ScalarAI->
setName(output->getName() +
".out");
1044 if (Count.has_value())
1062 if (!
I.getDebugLoc())
1066 if (isa<DbgInfoIntrinsic>(
I))
1086 auto *
II = dyn_cast<IntrinsicInst>(&
I);
1087 if (!
II || !
II->isLifetimeStartOrEnd())
1093 Value *Mem =
II->getOperand(1)->stripInBoundsOffsets();
1097 if (
II->getIntrinsicID() == Intrinsic::lifetime_start)
1098 LifetimesStart.
insert(Mem);
1099 II->eraseFromParent();
1116 bool InsertBefore) {
1117 for (
Value *Mem : Objects) {
1120 "Input memory not defined in original function");
1128 Marker->insertBefore(Term);
1132 if (!LifetimesStart.
empty()) {
1133 insertMarkers(Intrinsic::lifetime_start, LifetimesStart,
1137 if (!LifetimesEnd.
empty()) {
1138 insertMarkers(Intrinsic::lifetime_end, LifetimesEnd,
1143void CodeExtractor::moveCodeToFunction(
Function *newFunction) {
1144 auto newFuncIt = newFunction->
begin();
1147 Block->removeFromParent();
1154 newFuncIt = newFunction->
insert(std::next(newFuncIt),
Block);
1158void CodeExtractor::calculateNewCallTerminatorWeights(
1170 Distribution BranchDist;
1177 BlockNode ExitNode(i);
1180 BranchDist.addExit(ExitNode, ExitFreq);
1186 if (BranchDist.Total == 0) {
1192 BranchDist.normalize();
1195 for (
unsigned I = 0, E = BranchDist.Weights.size();
I < E; ++
I) {
1196 const auto &Weight = BranchDist.Weights[
I];
1199 BranchWeights[Weight.TargetNode.Index] = Weight.Amount;
1201 EdgeProbabilities[Weight.TargetNode.Index] = BP;
1205 LLVMContext::MD_prof,
1217 if (DVI->getFunction() != &
F)
1218 DVI->eraseFromParent();
1220 if (DVR->getFunction() != &
F)
1221 DVR->eraseFromParent();
1244 assert(OldSP->getUnit() &&
"Missing compile unit for subprogram");
1249 DISubprogram::SPFlagOptimized |
1250 DISubprogram::SPFlagLocalToUnit;
1253 0, SPType, 0, DINode::FlagZero, SPFlags);
1256 auto IsInvalidLocation = [&NewFunc](
Value *Location) {
1260 (!isa<Constant>(Location) && !isa<Instruction>(Location)))
1262 Instruction *LocationInst = dyn_cast<Instruction>(Location);
1263 return LocationInst && LocationInst->
getFunction() != &NewFunc;
1278 DINode *&NewVar = RemappedMetadata[OldVar];
1281 *OldVar->getScope(), *NewSP, Ctx, Cache);
1283 NewScope, OldVar->
getName(), OldVar->getFile(), OldVar->getLine(),
1284 OldVar->getType(),
false, DINode::FlagZero,
1285 OldVar->getAlignInBits());
1287 return cast<DILocalVariable>(NewVar);
1290 auto UpdateDbgLabel = [&](
auto *LabelRecord) {
1293 if (LabelRecord->getDebugLoc().getInlinedAt())
1295 DILabel *OldLabel = LabelRecord->getLabel();
1296 DINode *&NewLabel = RemappedMetadata[OldLabel];
1299 *OldLabel->
getScope(), *NewSP, Ctx, Cache);
1303 LabelRecord->setLabel(cast<DILabel>(NewLabel));
1306 auto UpdateDbgRecordsOnInst = [&](
Instruction &
I) ->
void {
1307 for (
DbgRecord &DR :
I.getDbgRecordRange()) {
1309 UpdateDbgLabel(DLR);
1330 UpdateDbgRecordsOnInst(
I);
1332 auto *DII = dyn_cast<DbgInfoIntrinsic>(&
I);
1338 if (
auto *DLI = dyn_cast<DbgLabelInst>(&
I)) {
1339 UpdateDbgLabel(DLI);
1343 auto *DVI = cast<DbgVariableIntrinsic>(DII);
1345 if (
any_of(DVI->location_ops(), IsInvalidLocation)) {
1350 if (
auto *DAI = dyn_cast<DbgAssignIntrinsic>(DVI);
1351 DAI && IsInvalidLocation(DAI->getAddress())) {
1357 if (!DVI->getDebugLoc().getInlinedAt())
1358 DVI->setVariable(GetUpdatedDIVariable(DVI->getVariable()));
1361 for (
auto *DII : DebugIntrinsicsToDelete)
1362 DII->eraseFromParent();
1363 for (
auto *DVR : DVRsToDelete)
1364 DVR->getMarker()->MarkedInstr->dropOneDbgRecord(DVR);
1376 *NewSP, Ctx, Cache));
1379 auto updateLoopInfoLoc = [&Ctx, &Cache, NewSP](
Metadata *MD) ->
Metadata * {
1380 if (
auto *Loc = dyn_cast_or_null<DILocation>(MD))
1410 normalizeCFGForExtraction(header);
1416 if (
auto *AI = dyn_cast<AssumeInst>(&
I)) {
1419 AI->eraseFromParent();
1424 ValueSet SinkingCands, HoistingCands;
1426 findAllocas(CEAC, SinkingCands, HoistingCands, CommonExit);
1439 if (!HoistingCands.
empty()) {
1442 for (
auto *
II : HoistingCands)
1444 computeExtractedFuncRetVals();
1454 assert(BPI &&
"Both BPI and BFI are required to preserve profile info");
1462 for (
BasicBlock *Succ : ExtractedFuncRetVals) {
1477 while (ReplIP &&
Blocks.count(ReplIP))
1481 std::string SuffixToUse =
1488 Function *newFunction = constructFunctionDeclaration(
1489 inputs, outputs, EntryFreq, oldFunction->
getName() +
"." + SuffixToUse,
1490 StructValues, StructTy);
1493 emitFunctionBody(inputs, outputs, StructValues, newFunction, StructTy, header,
1496 std::vector<Value *> Reloads;
1497 CallInst *TheCall = emitReplacerCall(
1498 inputs, outputs, StructValues, newFunction, StructTy, oldFunction, ReplIP,
1499 EntryFreq, LifetimesStart.
getArrayRef(), Reloads);
1501 insertReplacerCall(oldFunction, header, TheCall->
getParent(), outputs,
1502 Reloads, ExitWeights);
1507 newFunction->
dump();
1517void CodeExtractor::normalizeCFGForExtraction(
BasicBlock *&header) {
1520 splitReturnBlocks();
1523 severSplitPHINodesOfEntry(header);
1529 computeExtractedFuncRetVals();
1530 severSplitPHINodesOfExits();
1533void CodeExtractor::computeExtractedFuncRetVals() {
1534 ExtractedFuncRetVals.clear();
1542 bool IsNew = ExitBlocks.
insert(Succ).second;
1544 ExtractedFuncRetVals.push_back(Succ);
1549Type *CodeExtractor::getSwitchType() {
1552 assert(ExtractedFuncRetVals.size() < 0xffff &&
1553 "too many exit blocks for switch");
1554 switch (ExtractedFuncRetVals.size()) {
1566void CodeExtractor::emitFunctionBody(
1567 const ValueSet &inputs,
const ValueSet &outputs,
1568 const ValueSet &StructValues,
Function *newFunction,
1582 for (
auto *
II : SinkingCands) {
1583 if (!isa<AllocaInst>(
II)) {
1584 cast<Instruction>(
II)->moveBefore(*newFuncRoot,
1588 for (
auto *
II : SinkingCands) {
1589 if (
auto *AI = dyn_cast<AllocaInst>(
II)) {
1595 Argument *AggArg = StructValues.empty()
1602 for (
unsigned i = 0, e = inputs.size(), aggIdx = 0; i != e; ++i) {
1604 if (StructValues.contains(inputs[i])) {
1609 StructArgTy, AggArg,
Idx,
"gep_" + inputs[i]->
getName(), newFuncRoot);
1611 "loadgep_" + inputs[i]->getName(), newFuncRoot);
1614 RewriteVal = &*ScalarAI++;
1619 moveCodeToFunction(newFunction);
1621 for (
unsigned i = 0, e = inputs.size(); i != e; ++i) {
1622 Value *RewriteVal = NewValues[i];
1624 std::vector<User *>
Users(inputs[i]->user_begin(), inputs[i]->user_end());
1627 if (
Blocks.count(inst->getParent()))
1628 inst->replaceUsesOfWith(inputs[i], RewriteVal);
1636 std::map<BasicBlock *, BasicBlock *> ExitBlockMap;
1640 for (
auto P :
enumerate(ExtractedFuncRetVals)) {
1642 size_t SuccNum =
P.index();
1645 Context, OldTarget->
getName() +
".exitStub", newFunction);
1646 ExitBlockMap[OldTarget] = NewTarget;
1648 Value *brVal =
nullptr;
1650 assert(ExtractedFuncRetVals.size() < 0xffff &&
1651 "too many exit blocks for switch");
1652 switch (ExtractedFuncRetVals.size()) {
1658 brVal = ConstantInt::get(
RetTy, !SuccNum);
1661 brVal = ConstantInt::get(
RetTy, SuccNum);
1675 BasicBlock *NewTarget = ExitBlockMap[OldTarget];
1676 assert(NewTarget &&
"Unknown target block!");
1700 unsigned AggIdx = 0;
1702 for (
Value *Input : inputs) {
1703 if (StructValues.contains(Input))
1709 for (
Value *Output : outputs) {
1715 if (
auto *InvokeI = dyn_cast<InvokeInst>(Output))
1716 InsertPt = InvokeI->getNormalDest()->getFirstInsertionPt();
1717 else if (
auto *Phi = dyn_cast<PHINode>(Output))
1718 InsertPt =
Phi->getParent()->getFirstInsertionPt();
1719 else if (
auto *OutI = dyn_cast<Instruction>(Output))
1720 InsertPt = std::next(OutI->getIterator());
1723 if (StructValues.contains(Output))
1730 assert((InsertPt->getFunction() == newFunction ||
1731 Blocks.count(InsertPt->getParent())) &&
1732 "InsertPt should be in new function");
1734 if (StructValues.contains(Output)) {
1735 assert(AggArg &&
"Number of aggregate output arguments should match "
1736 "the number of defined values");
1741 StructArgTy, AggArg,
Idx,
"gep_" + Output->getName(), InsertPt);
1746 "Number of scalar output arguments should match "
1747 "the number of defined values");
1748 new StoreInst(Output, &*ScalarAI, InsertPt);
1753 if (ExtractedFuncRetVals.empty()) {
1759 return isa<ReturnInst>(Term) || isa<ResumeInst>(Term);
1765CallInst *CodeExtractor::emitReplacerCall(
1766 const ValueSet &inputs,
const ValueSet &outputs,
1767 const ValueSet &StructValues,
Function *newFunction,
1770 std::vector<Value *> &Reloads) {
1780 AllocationBlock ? AllocationBlock : &oldFunction->
getEntryBlock();
1787 std::vector<Value *> params;
1790 for (
Value *input : inputs) {
1791 if (StructValues.contains(input))
1794 params.push_back(input);
1798 std::vector<Value *> ReloadOutputs;
1799 for (
Value *output : outputs) {
1800 if (StructValues.contains(output))
1804 output->getType(),
DL.getAllocaAddrSpace(),
nullptr,
1806 params.push_back(alloca);
1807 ReloadOutputs.push_back(alloca);
1811 if (!StructValues.empty()) {
1814 if (ArgsInZeroAddressSpace &&
DL.getAllocaAddrSpace() != 0) {
1816 Struct, PointerType ::get(Context, 0),
"structArg.ascast");
1817 StructSpaceCast->insertAfter(
Struct);
1818 params.push_back(StructSpaceCast);
1820 params.push_back(
Struct);
1823 unsigned AggIdx = 0;
1824 for (
Value *input : inputs) {
1825 if (!StructValues.contains(input))
1832 StructArgTy,
Struct,
Idx,
"gep_" + input->getName());
1833 GEP->insertInto(codeReplacer, codeReplacer->
end());
1842 newFunction, params, ExtractedFuncRetVals.size() > 1 ?
"targetBlock" :
"",
1846 unsigned ParamIdx = 0;
1847 unsigned AggIdx = 0;
1848 for (
auto input : inputs) {
1849 if (StructValues.contains(input)) {
1852 if (input->isSwiftError())
1869 for (
unsigned i = 0, e = outputs.size(), scalarIdx = 0; i != e; ++i) {
1870 Value *Output =
nullptr;
1871 if (StructValues.contains(outputs[i])) {
1877 GEP->insertInto(codeReplacer, codeReplacer->
end());
1881 Output = ReloadOutputs[scalarIdx];
1886 outputs[i]->
getName() +
".reload", codeReplacer);
1887 Reloads.push_back(
load);
1893 codeReplacer, 0, codeReplacer);
1894 for (
auto P :
enumerate(ExtractedFuncRetVals)) {
1896 size_t SuccNum =
P.index();
1903 Type *OldFnRetTy = TheSwitch->
getParent()->getParent()->getReturnType();
1904 switch (ExtractedFuncRetVals.size()) {
1912 }
else if (OldFnRetTy->
isVoidTy()) {
1967void CodeExtractor::insertReplacerCall(
1976 for (
auto &U :
Users)
1980 if (
I->isTerminator() &&
I->getFunction() == oldFunction &&
1981 !
Blocks.count(
I->getParent()))
1982 I->replaceUsesOfWith(header, codeReplacer);
1988 for (
BasicBlock *ExitBB : ExtractedFuncRetVals)
1989 for (
PHINode &PN : ExitBB->phis()) {
1990 Value *IncomingCodeReplacerVal =
nullptr;
1997 if (!IncomingCodeReplacerVal) {
2002 "PHI has two incompatbile incoming values from codeRepl");
2006 for (
unsigned i = 0, e = outputs.size(); i != e; ++i) {
2008 std::vector<User *>
Users(outputs[i]->user_begin(), outputs[i]->user_end());
2011 if (inst->
getParent()->getParent() == oldFunction)
2017 if (BFI && ExtractedFuncRetVals.size() > 1)
2018 calculateNewCallTerminatorWeights(codeReplacer, ExitWeights, BPI);
2025 auto *
I = dyn_cast_or_null<CallInst>(AssumeVH);
2030 if (
I->getFunction() != &OldFunc)
2037 auto *AffectedCI = dyn_cast_or_null<CallInst>(AffectedValVH);
2040 if (AffectedCI->getFunction() != &OldFunc)
2042 auto *AssumedInst = cast<Instruction>(AffectedCI->getOperand(0));
2043 if (AssumedInst->getFunction() != &OldFunc)
2051 ExcludeArgsFromAggregate.
insert(Arg);
AMDGPU Mark last scratch load
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Expand Atomic instructions
This file contains the simple types necessary to represent the attributes associated with functions a...
static const Function * getParent(const Value *V)
Analysis containing CSE Info
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Given that RA is a live value
This file defines the DenseMap class.
DenseMap< Block *, BlockRelaxAux > Blocks
static Function * getFunction(Constant *C)
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
Module.h This file contains the declarations for the Module class.
iv Induction Variable Users
Move duplicate certain instructions close to their use
uint64_t IntrinsicInst * II
static StringRef getName(Value *V)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
This class represents a conversion between pointers from one address space to another.
an instruction to allocate memory on the stack
This class represents an incoming formal argument to a Function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
empty - Check if the array is empty.
A cache of @llvm.assume calls within a function.
MutableArrayRef< ResultElem > assumptions()
Access the list of assumption handles currently tracked for this function.
void unregisterAssumption(AssumeInst *CI)
Remove an @llvm.assume intrinsic from this function's cache if it has been added to the cache earlier...
MutableArrayRef< ResultElem > assumptionsFor(const Value *V)
Access the list of assumptions which affect this value.
AttributeSet getFnAttrs() const
The function attributes are returned.
@ TombstoneKey
Use as Tombstone key for DenseMap of AttrKind.
@ None
No attributes have been set.
@ EmptyKey
Use as Empty key for DenseMap of AttrKind.
@ EndAttrKinds
Sentinel value useful for loops.
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
iterator_range< filter_iterator< BasicBlock::const_iterator, std::function< bool(const Instruction &)> > > instructionsWithoutDebug(bool SkipPseudoOp=true) const
Return a const iterator range over the instructions in the block, skipping any debug instructions.
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches,...
InstListType::const_iterator getFirstNonPHIIt() const
Iterator returning form of getFirstNonPHI.
InstListType::const_iterator const_iterator
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="", bool Before=false)
Split the basic block into two basic blocks at the specified instruction.
const Function * getParent() const
Return the enclosing method, or null if none.
InstListType::iterator iterator
Instruction iterators...
LLVMContext & getContext() const
Get the context in which this basic block lives.
bool IsNewDbgInfoFormat
Flag recording whether or not this block stores debug-info in the form of intrinsic instructions (fal...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
std::optional< uint64_t > getProfileCountFromFreq(BlockFrequency Freq) const
Returns the estimated profile count of Freq.
void setBlockFreq(const BasicBlock *BB, BlockFrequency Freq)
BlockFrequency getBlockFreq(const BasicBlock *BB) const
getblockFreq - Return block frequency.
Conditional or Unconditional Branch instruction.
static BranchInst * Create(BasicBlock *IfTrue, InsertPosition InsertBefore=nullptr)
Analysis providing branch probability information.
void setEdgeProbability(const BasicBlock *Src, const SmallVectorImpl< BranchProbability > &Probs)
Set the raw probabilities for all edges from the given block.
BranchProbability getEdgeProbability(const BasicBlock *Src, unsigned IndexInSuccessors) const
Get an edge's probability, relative to other out-edges of the Src.
static BranchProbability getUnknown()
static BranchProbability getZero()
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
This class represents a function call, abstracting a target machine's calling convention.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
This is the base class for all instructions that perform data casts.
static CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
DISubroutineType * createSubroutineType(DITypeRefArray ParameterTypes, DINode::DIFlags Flags=DINode::FlagZero, unsigned CC=0)
Create subroutine type.
void finalizeSubprogram(DISubprogram *SP)
Finalize a specific subprogram - no new variables may be added to this subprogram afterwards.
DISubprogram * createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine, DINode::DIFlags Flags=DINode::FlagZero, DISubprogram::DISPFlags SPFlags=DISubprogram::SPFlagZero, DITemplateParameterArray TParams=nullptr, DISubprogram *Decl=nullptr, DITypeArray ThrownTypes=nullptr, DINodeArray Annotations=nullptr, StringRef TargetFuncName="")
Create a new descriptor for the specified subprogram.
DITypeRefArray getOrCreateTypeArray(ArrayRef< Metadata * > Elements)
Get a DITypeRefArray, create one if required.
DILocalVariable * createAutoVariable(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve=false, DINode::DIFlags Flags=DINode::FlagZero, uint32_t AlignInBits=0)
Create a new descriptor for an auto variable.
StringRef getName() const
DILocalScope * getScope() const
Get the local scope for this label.
static DILocalScope * cloneScopeForSubprogram(DILocalScope &RootScope, DISubprogram &NewSP, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &Cache)
Traverses the scope chain rooted at RootScope until it hits a Subprogram, recreating the chain with "...
Tagged DWARF-like metadata node.
StringRef getName() const
DISPFlags
Debug info subprogram flags.
A parsed version of the target data layout string in and methods for querying it.
Records a position in IR for a source label (DILabel).
Base class for non-instruction debug metadata records that have positions within IR.
DebugLoc getDebugLoc() const
This is the common base class for debug info intrinsics for variables.
Record of a variable value-assignment, aka a non instruction representation of the dbg....
void setVariable(DILocalVariable *NewVar)
Value * getAddress() const
DILocalVariable * getVariable() const
iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
static DebugLoc replaceInlinedAtSubprogram(const DebugLoc &DL, DISubprogram &NewSP, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &Cache)
Rebuild the entire inline-at chain by replacing the subprogram at the end of the chain with NewSP.
DILocation * getInlinedAt() const
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
void changeImmediateDominator(DomTreeNodeBase< NodeT > *N, DomTreeNodeBase< NodeT > *NewIDom)
changeImmediateDominator - This method is used to update the dominator tree information when a node's...
DomTreeNodeBase< NodeT > * addNewBlock(NodeT *BB, NodeT *DomBB)
Add a new node to the dominator tree information.
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Class to represent profile counts.
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
void setSubprogram(DISubprogram *SP)
Set the attached subprogram.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
const BasicBlock & getEntryBlock() const
DISubprogram * getSubprogram() const
Get the attached subprogram.
bool IsNewDbgInfoFormat
Is this function using intrinsics to record the position of debugging information,...
bool hasPersonalityFn() const
Check whether this function has a personality function.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
void setPersonalityFn(Constant *Fn)
AttributeList getAttributes() const
Return the attribute list for this Function.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
adds the attribute to the list of attributes for the given arg.
Function::iterator insert(Function::iterator Position, BasicBlock *BB)
Insert BB in the basic block list at Position.
bool doesNotReturn() const
Determine if the function cannot return.
Argument * getArg(unsigned i) const
void setEntryCount(ProfileCount Count, const DenseSet< GlobalValue::GUID > *Imports=nullptr)
Set the entry count for this function.
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
unsigned getAddressSpace() const
Module * getParent()
Get the module that this global value is contained inside of...
@ InternalLinkage
Rename collisions when linking (static functions).
bool isLifetimeStartOrEnd() const LLVM_READONLY
Return true if the instruction is a llvm.lifetime.start or llvm.lifetime.end marker.
unsigned getNumSuccessors() const LLVM_READONLY
Return the number of successors that this instruction has.
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
const Function * getFunction() const
Return the function this instruction belongs to.
BasicBlock * getSuccessor(unsigned Idx) const LLVM_READONLY
Return the specified successor. This instruction must be a terminator.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
void setSuccessor(unsigned Idx, BasicBlock *BB)
Update the specified successor to point at the provided block.
void moveBefore(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
A wrapper class for inspecting calls to intrinsic functions.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
This is an important class for using LLVM in a threaded context.
An instruction for reading from memory.
Value * getPointerOperand()
MDNode * createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight, bool IsExpected=false)
Return metadata containing two branch weights.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
A Module instance is used to store all the information related to an LLVM module.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
void setIncomingBlock(unsigned i, BasicBlock *BB)
Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
Remove an incoming value.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Return a value (possibly void), from a function.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, InsertPosition InsertBefore=nullptr)
A vector that has set insertion semantics.
ArrayRef< value_type > getArrayRef() const
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
bool empty() const
Determine if the SetVector is empty or not.
bool insert(const value_type &X)
Insert a new element into the SetVector.
bool contains(const key_type &key) const
Check if the SetVector contains the given key.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
std::string str() const
str - Get the contents as an std::string.
constexpr bool empty() const
empty - Check if the string is empty.
Class to represent struct types.
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Type * getElementType(unsigned N) const
BasicBlock * getSuccessor(unsigned idx) const
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, InsertPosition InsertBefore=nullptr)
void setCondition(Value *V)
void addCase(ConstantInt *OnVal, BasicBlock *Dest)
Add an entry to the switch instruction.
void setDefaultDest(BasicBlock *DefaultCase)
Value * getCondition() const
CaseIt removeCase(CaseIt I)
This method removes the specified case and its successor from the switch instruction.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
static IntegerType * getInt1Ty(LLVMContext &C)
static Type * getVoidTy(LLVMContext &C)
static IntegerType * getInt16Ty(LLVMContext &C)
static IntegerType * getInt32Ty(LLVMContext &C)
static IntegerType * getInt64Ty(LLVMContext &C)
bool isVoidTy() const
Return true if this is 'void'.
This function has undefined behavior.
bool replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
user_iterator user_begin()
void setName(const Twine &Name)
Change the name of the value.
const Value * stripInBoundsConstantOffsets() const
Strip off pointer casts and all-constant inbounds GEPs.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVMContext & getContext() const
All values hold a context through their type.
StringRef getName() const
Return a constant reference to the value's name.
void dump() const
Support for debugging, callable in GDB: V->dump()
const ParentTy * getParent() const
self_iterator getIterator()
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
void remapAssignID(DenseMap< DIAssignID *, DIAssignID * > &Map, Instruction &I)
Replace DIAssignID uses and attachments with IDs from Map.
NodeAddr< PhiNode * > Phi
This is an optimization pass for GlobalISel generic memory operations.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
bool stripDebugInfo(Function &F)
Function::ProfileCount ProfileCount
bool verifyFunction(const Function &F, raw_ostream *OS=nullptr)
Check a function for errors, useful for use when debugging a pass.
void findDbgUsers(SmallVectorImpl< DbgVariableIntrinsic * > &DbgInsts, Value *V, SmallVectorImpl< DbgVariableRecord * > *DbgVariableRecords=nullptr)
Finds the debug info intrinsics describing a value.
auto successors(const MachineBasicBlock *BB)
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
auto reverse(ContainerTy &&C)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
BasicBlock * SplitBlock(BasicBlock *Old, BasicBlock::iterator SplitPt, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="", bool Before=false)
Split the specified block at the specified instruction.
auto predecessors(const MachineBasicBlock *BB)
void updateLoopMetadataDebugLocations(Instruction &I, function_ref< Metadata *(Metadata *)> Updater)
Update the debug locations contained within the MD_loop metadata attached to the instruction I,...
Representative of a block.
Distribution of unscaled probability weight.