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()) {
538 auto *IntrInst = dyn_cast<LifetimeIntrinsic>(BU);
546 << *Bitcast <<
" in out-of-region lifetime marker "
547 << *IntrInst <<
"\n");
548 LifetimeBitcastUsers.
push_back(IntrInst);
558 I->replaceUsesOfWith(
I->getOperand(1), CastI);
564 for (
User *U : AI->users()) {
565 if (U->stripInBoundsConstantOffsets() == AI) {
567 LifetimeMarkerInfo LMI = getLifetimeMarkers(CEAC, Bitcast, ExitBlock);
583 if (Bitcasts.
empty())
586 LLVM_DEBUG(
dbgs() <<
"Sinking alloca (via bitcast): " << *AI <<
"\n");
588 for (
unsigned I = 0, E = Bitcasts.
size();
I != E; ++
I) {
590 const LifetimeMarkerInfo &LMI = BitcastLifetimeInfo[
I];
592 "Unsafe to sink bitcast without lifetime markers");
593 moveOrIgnoreLifetimeMarkers(LMI);
595 LLVM_DEBUG(
dbgs() <<
"Sinking bitcast-of-alloca: " << *BitcastAddr
597 SinkCands.
insert(BitcastAddr);
611 if (AllowVarArgs &&
F->getFunctionType()->isVarArg()) {
612 auto containsVarArgIntrinsic = [](
const Instruction &
I) {
613 if (
const CallInst *CI = dyn_cast<CallInst>(&
I))
614 if (
const Function *Callee = CI->getCalledFunction())
615 return Callee->getIntrinsicID() == Intrinsic::vastart ||
616 Callee->getIntrinsicID() == Intrinsic::vaend;
620 for (
auto &BB : *
F) {
621 if (Blocks.count(&BB))
635 bool IsSave =
II->getIntrinsicID() == Intrinsic::stacksave;
636 bool IsRestore =
II->getIntrinsicID() == Intrinsic::stackrestore;
637 if (IsSave &&
any_of(
II->users(), [&Blks = this->Blocks](
User *U) {
638 return !definedInRegion(Blks, U);
650 bool CollectGlobalInputs)
const {
655 for (
auto &OI :
II.operands()) {
657 if (!SinkCands.
count(V) &&
659 (CollectGlobalInputs && llvm::isa<llvm::GlobalVariable>(V))))
663 for (
User *U :
II.users())
675void CodeExtractor::severSplitPHINodesOfEntry(
BasicBlock *&Header) {
676 unsigned NumPredsFromRegion = 0;
677 unsigned NumPredsOutsideRegion = 0;
679 if (Header != &Header->getParent()->getEntryBlock()) {
680 PHINode *PN = dyn_cast<PHINode>(Header->begin());
688 ++NumPredsFromRegion;
690 ++NumPredsOutsideRegion;
694 if (NumPredsOutsideRegion <= 1)
return;
706 Blocks.remove(OldPred);
707 Blocks.insert(NewBB);
712 if (NumPredsFromRegion) {
725 for (AfterPHIs = OldPred->
begin(); isa<PHINode>(AfterPHIs); ++AfterPHIs) {
726 PHINode *PN = cast<PHINode>(AfterPHIs);
752void CodeExtractor::severSplitPHINodesOfExits() {
753 for (
BasicBlock *ExitBB : ExtractedFuncRetVals) {
756 for (
PHINode &PN : ExitBB->phis()) {
766 if (IncomingVals.
size() <= 1)
773 ExitBB->getName() +
".split",
774 ExitBB->getParent(), ExitBB);
778 if (Blocks.count(PredBB))
779 PredBB->getTerminator()->replaceUsesOfWith(ExitBB, NewBB);
781 Blocks.insert(NewBB);
788 for (
unsigned i : IncomingVals)
790 for (
unsigned i :
reverse(IncomingVals))
797void CodeExtractor::splitReturnBlocks() {
801 Block->splitBasicBlock(RI->getIterator(),
Block->getName() +
".ret");
817Function *CodeExtractor::constructFunctionDeclaration(
818 const ValueSet &inputs,
const ValueSet &outputs,
BlockFrequency EntryFreq,
827 std::vector<Type *> ParamTy;
828 std::vector<Type *> AggParamTy;
834 if (AggregateArgs && !ExcludeArgsFromAggregate.
contains(
value)) {
835 AggParamTy.push_back(
value->getType());
836 StructValues.insert(
value);
838 ParamTy.push_back(
value->getType());
842 for (
Value *output : outputs) {
844 if (AggregateArgs && !ExcludeArgsFromAggregate.
contains(output)) {
845 AggParamTy.push_back(output->getType());
846 StructValues.insert(output);
853 (ParamTy.size() + AggParamTy.size()) ==
854 (inputs.size() + outputs.size()) &&
855 "Number of scalar and aggregate params does not match inputs, outputs");
856 assert((StructValues.empty() || AggregateArgs) &&
857 "Expeced StructValues only with AggregateArgs set");
860 if (!AggParamTy.empty()) {
863 M->getContext(), ArgsInZeroAddressSpace ? 0 :
DL.getAllocaAddrSpace()));
868 dbgs() <<
"Function type: " << *
RetTy <<
" f(";
869 for (
Type *i : ParamTy)
870 dbgs() << *i <<
", ";
894 if (Attr.isStringAttribute()) {
895 if (Attr.getKindAsString() ==
"thunk")
898 switch (Attr.getKindAsEnum()) {
901 case Attribute::AllocSize:
902 case Attribute::Builtin:
903 case Attribute::Convergent:
904 case Attribute::JumpTable:
905 case Attribute::Naked:
906 case Attribute::NoBuiltin:
907 case Attribute::NoMerge:
908 case Attribute::NoReturn:
909 case Attribute::NoSync:
910 case Attribute::ReturnsTwice:
911 case Attribute::Speculatable:
912 case Attribute::StackAlignment:
913 case Attribute::WillReturn:
914 case Attribute::AllocKind:
915 case Attribute::PresplitCoroutine:
916 case Attribute::Memory:
917 case Attribute::NoFPClass:
918 case Attribute::CoroDestroyOnlyWhenComplete:
919 case Attribute::CoroElideSafe:
920 case Attribute::NoDivergenceSource:
923 case Attribute::AlwaysInline:
924 case Attribute::Cold:
925 case Attribute::DisableSanitizerInstrumentation:
926 case Attribute::FnRetThunkExtern:
928 case Attribute::HybridPatchable:
929 case Attribute::NoRecurse:
930 case Attribute::InlineHint:
931 case Attribute::MinSize:
932 case Attribute::NoCallback:
933 case Attribute::NoDuplicate:
934 case Attribute::NoFree:
935 case Attribute::NoImplicitFloat:
936 case Attribute::NoInline:
937 case Attribute::NonLazyBind:
938 case Attribute::NoRedZone:
939 case Attribute::NoUnwind:
940 case Attribute::NoSanitizeBounds:
941 case Attribute::NoSanitizeCoverage:
942 case Attribute::NullPointerIsValid:
943 case Attribute::OptimizeForDebugging:
944 case Attribute::OptForFuzzing:
945 case Attribute::OptimizeNone:
946 case Attribute::OptimizeForSize:
947 case Attribute::SafeStack:
948 case Attribute::ShadowCallStack:
949 case Attribute::SanitizeAddress:
950 case Attribute::SanitizeMemory:
951 case Attribute::SanitizeNumericalStability:
952 case Attribute::SanitizeThread:
953 case Attribute::SanitizeType:
954 case Attribute::SanitizeHWAddress:
955 case Attribute::SanitizeMemTag:
956 case Attribute::SanitizeRealtime:
957 case Attribute::SanitizeRealtimeBlocking:
958 case Attribute::SpeculativeLoadHardening:
959 case Attribute::StackProtect:
960 case Attribute::StackProtectReq:
961 case Attribute::StackProtectStrong:
962 case Attribute::StrictFP:
963 case Attribute::UWTable:
964 case Attribute::VScaleRange:
965 case Attribute::NoCfCheck:
966 case Attribute::MustProgress:
967 case Attribute::NoProfile:
968 case Attribute::SkipProfile:
971 case Attribute::Alignment:
972 case Attribute::AllocatedPointer:
973 case Attribute::AllocAlign:
974 case Attribute::ByVal:
975 case Attribute::Captures:
976 case Attribute::Dereferenceable:
977 case Attribute::DereferenceableOrNull:
978 case Attribute::ElementType:
979 case Attribute::InAlloca:
980 case Attribute::InReg:
981 case Attribute::Nest:
982 case Attribute::NoAlias:
983 case Attribute::NoUndef:
984 case Attribute::NonNull:
985 case Attribute::Preallocated:
986 case Attribute::ReadNone:
987 case Attribute::ReadOnly:
988 case Attribute::Returned:
989 case Attribute::SExt:
990 case Attribute::StructRet:
991 case Attribute::SwiftError:
992 case Attribute::SwiftSelf:
993 case Attribute::SwiftAsync:
994 case Attribute::ZExt:
995 case Attribute::ImmArg:
996 case Attribute::ByRef:
997 case Attribute::WriteOnly:
998 case Attribute::Writable:
999 case Attribute::DeadOnUnwind:
1000 case Attribute::Range:
1001 case Attribute::Initializes:
1002 case Attribute::NoExt:
1020 for (
Value *input : inputs) {
1021 if (StructValues.contains(input))
1024 ScalarAI->
setName(input->getName());
1025 if (input->isSwiftError())
1027 Attribute::SwiftError);
1030 for (
Value *output : outputs) {
1031 if (StructValues.contains(output))
1034 ScalarAI->
setName(output->getName() +
".out");
1041 if (Count.has_value())
1059 if (!
I.getDebugLoc())
1063 if (isa<DbgInfoIntrinsic>(
I))
1083 auto *
II = dyn_cast<LifetimeIntrinsic>(&
I);
1090 Value *Mem =
II->getOperand(1)->stripInBoundsOffsets();
1094 if (
II->getIntrinsicID() == Intrinsic::lifetime_start)
1095 LifetimesStart.
insert(Mem);
1096 II->eraseFromParent();
1113 bool InsertBefore) {
1114 for (
Value *Mem : Objects) {
1117 "Input memory not defined in original function");
1125 Marker->insertBefore(Term->getIterator());
1129 if (!LifetimesStart.
empty()) {
1130 insertMarkers(Intrinsic::lifetime_start, LifetimesStart,
1134 if (!LifetimesEnd.
empty()) {
1135 insertMarkers(Intrinsic::lifetime_end, LifetimesEnd,
1140void CodeExtractor::moveCodeToFunction(
Function *newFunction) {
1141 auto newFuncIt = newFunction->
begin();
1144 Block->removeFromParent();
1151 newFuncIt = newFunction->
insert(std::next(newFuncIt),
Block);
1155void CodeExtractor::calculateNewCallTerminatorWeights(
1167 Distribution BranchDist;
1174 BlockNode ExitNode(i);
1177 BranchDist.addExit(ExitNode, ExitFreq);
1183 if (BranchDist.Total == 0) {
1189 BranchDist.normalize();
1192 for (
unsigned I = 0, E = BranchDist.Weights.size();
I < E; ++
I) {
1193 const auto &Weight = BranchDist.Weights[
I];
1196 BranchWeights[Weight.TargetNode.Index] = Weight.Amount;
1198 EdgeProbabilities[Weight.TargetNode.Index] = BP;
1202 LLVMContext::MD_prof,
1214 if (DVI->getFunction() != &
F)
1215 DVI->eraseFromParent();
1217 if (DVR->getFunction() != &
F)
1218 DVR->eraseFromParent();
1241 assert(OldSP->getUnit() &&
"Missing compile unit for subprogram");
1246 DISubprogram::SPFlagOptimized |
1247 DISubprogram::SPFlagLocalToUnit;
1250 0, SPType, 0, DINode::FlagZero, SPFlags);
1253 auto IsInvalidLocation = [&NewFunc](
Value *Location) {
1257 (!isa<Constant>(Location) && !isa<Instruction>(Location)))
1259 Instruction *LocationInst = dyn_cast<Instruction>(Location);
1260 return LocationInst && LocationInst->
getFunction() != &NewFunc;
1275 DINode *&NewVar = RemappedMetadata[OldVar];
1278 *OldVar->getScope(), *NewSP, Ctx, Cache);
1280 NewScope, OldVar->
getName(), OldVar->getFile(), OldVar->getLine(),
1281 OldVar->getType(),
false, DINode::FlagZero,
1282 OldVar->getAlignInBits());
1284 return cast<DILocalVariable>(NewVar);
1287 auto UpdateDbgLabel = [&](
auto *LabelRecord) {
1290 if (LabelRecord->getDebugLoc().getInlinedAt())
1292 DILabel *OldLabel = LabelRecord->getLabel();
1293 DINode *&NewLabel = RemappedMetadata[OldLabel];
1296 *OldLabel->
getScope(), *NewSP, Ctx, Cache);
1300 LabelRecord->setLabel(cast<DILabel>(NewLabel));
1303 auto UpdateDbgRecordsOnInst = [&](
Instruction &
I) ->
void {
1304 for (
DbgRecord &DR :
I.getDbgRecordRange()) {
1306 UpdateDbgLabel(DLR);
1327 UpdateDbgRecordsOnInst(
I);
1329 auto *DII = dyn_cast<DbgInfoIntrinsic>(&
I);
1335 if (
auto *DLI = dyn_cast<DbgLabelInst>(&
I)) {
1336 UpdateDbgLabel(DLI);
1340 auto *DVI = cast<DbgVariableIntrinsic>(DII);
1342 if (
any_of(DVI->location_ops(), IsInvalidLocation)) {
1347 if (
auto *DAI = dyn_cast<DbgAssignIntrinsic>(DVI);
1348 DAI && IsInvalidLocation(DAI->getAddress())) {
1354 if (!DVI->getDebugLoc().getInlinedAt())
1355 DVI->setVariable(GetUpdatedDIVariable(DVI->getVariable()));
1358 for (
auto *DII : DebugIntrinsicsToDelete)
1359 DII->eraseFromParent();
1360 for (
auto *DVR : DVRsToDelete)
1361 DVR->getMarker()->MarkedInstr->dropOneDbgRecord(DVR);
1373 *NewSP, Ctx, Cache));
1376 auto updateLoopInfoLoc = [&Ctx, &Cache, NewSP](
Metadata *MD) ->
Metadata * {
1377 if (
auto *Loc = dyn_cast_or_null<DILocation>(MD))
1407 normalizeCFGForExtraction(header);
1413 if (
auto *AI = dyn_cast<AssumeInst>(&
I)) {
1416 AI->eraseFromParent();
1421 ValueSet SinkingCands, HoistingCands;
1423 findAllocas(CEAC, SinkingCands, HoistingCands, CommonExit);
1436 if (!HoistingCands.
empty()) {
1439 for (
auto *
II : HoistingCands)
1441 computeExtractedFuncRetVals();
1451 assert(BPI &&
"Both BPI and BFI are required to preserve profile info");
1459 for (
BasicBlock *Succ : ExtractedFuncRetVals) {
1474 while (ReplIP &&
Blocks.count(ReplIP))
1478 std::string SuffixToUse =
1485 Function *newFunction = constructFunctionDeclaration(
1486 inputs, outputs, EntryFreq, oldFunction->
getName() +
"." + SuffixToUse,
1487 StructValues, StructTy);
1490 emitFunctionBody(inputs, outputs, StructValues, newFunction, StructTy, header,
1493 std::vector<Value *> Reloads;
1494 CallInst *TheCall = emitReplacerCall(
1495 inputs, outputs, StructValues, newFunction, StructTy, oldFunction, ReplIP,
1496 EntryFreq, LifetimesStart.
getArrayRef(), Reloads);
1498 insertReplacerCall(oldFunction, header, TheCall->
getParent(), outputs,
1499 Reloads, ExitWeights);
1504 newFunction->
dump();
1514void CodeExtractor::normalizeCFGForExtraction(
BasicBlock *&header) {
1517 splitReturnBlocks();
1520 severSplitPHINodesOfEntry(header);
1526 computeExtractedFuncRetVals();
1527 severSplitPHINodesOfExits();
1530void CodeExtractor::computeExtractedFuncRetVals() {
1531 ExtractedFuncRetVals.clear();
1539 bool IsNew = ExitBlocks.
insert(Succ).second;
1541 ExtractedFuncRetVals.push_back(Succ);
1546Type *CodeExtractor::getSwitchType() {
1549 assert(ExtractedFuncRetVals.size() < 0xffff &&
1550 "too many exit blocks for switch");
1551 switch (ExtractedFuncRetVals.size()) {
1563void CodeExtractor::emitFunctionBody(
1564 const ValueSet &inputs,
const ValueSet &outputs,
1565 const ValueSet &StructValues,
Function *newFunction,
1579 for (
auto *
II : SinkingCands) {
1580 if (!isa<AllocaInst>(
II)) {
1581 cast<Instruction>(
II)->moveBefore(*newFuncRoot,
1585 for (
auto *
II : SinkingCands) {
1586 if (
auto *AI = dyn_cast<AllocaInst>(
II)) {
1592 Argument *AggArg = StructValues.empty()
1599 for (
unsigned i = 0, e = inputs.size(), aggIdx = 0; i != e; ++i) {
1601 if (StructValues.contains(inputs[i])) {
1606 StructArgTy, AggArg,
Idx,
"gep_" + inputs[i]->
getName(), newFuncRoot);
1608 "loadgep_" + inputs[i]->getName(), newFuncRoot);
1611 RewriteVal = &*ScalarAI++;
1616 moveCodeToFunction(newFunction);
1618 for (
unsigned i = 0, e = inputs.size(); i != e; ++i) {
1619 Value *RewriteVal = NewValues[i];
1621 std::vector<User *>
Users(inputs[i]->user_begin(), inputs[i]->user_end());
1624 if (
Blocks.count(inst->getParent()))
1625 inst->replaceUsesOfWith(inputs[i], RewriteVal);
1633 std::map<BasicBlock *, BasicBlock *> ExitBlockMap;
1637 for (
auto P :
enumerate(ExtractedFuncRetVals)) {
1639 size_t SuccNum =
P.index();
1642 Context, OldTarget->
getName() +
".exitStub", newFunction);
1643 ExitBlockMap[OldTarget] = NewTarget;
1645 Value *brVal =
nullptr;
1647 assert(ExtractedFuncRetVals.size() < 0xffff &&
1648 "too many exit blocks for switch");
1649 switch (ExtractedFuncRetVals.size()) {
1655 brVal = ConstantInt::get(
RetTy, !SuccNum);
1658 brVal = ConstantInt::get(
RetTy, SuccNum);
1672 BasicBlock *NewTarget = ExitBlockMap[OldTarget];
1673 assert(NewTarget &&
"Unknown target block!");
1697 unsigned AggIdx = 0;
1699 for (
Value *Input : inputs) {
1700 if (StructValues.contains(Input))
1706 for (
Value *Output : outputs) {
1712 if (
auto *InvokeI = dyn_cast<InvokeInst>(Output))
1713 InsertPt = InvokeI->getNormalDest()->getFirstInsertionPt();
1714 else if (
auto *Phi = dyn_cast<PHINode>(Output))
1715 InsertPt =
Phi->getParent()->getFirstInsertionPt();
1716 else if (
auto *OutI = dyn_cast<Instruction>(Output))
1717 InsertPt = std::next(OutI->getIterator());
1720 if (StructValues.contains(Output))
1727 assert((InsertPt->getFunction() == newFunction ||
1728 Blocks.count(InsertPt->getParent())) &&
1729 "InsertPt should be in new function");
1731 if (StructValues.contains(Output)) {
1732 assert(AggArg &&
"Number of aggregate output arguments should match "
1733 "the number of defined values");
1738 StructArgTy, AggArg,
Idx,
"gep_" + Output->getName(), InsertPt);
1743 "Number of scalar output arguments should match "
1744 "the number of defined values");
1745 new StoreInst(Output, &*ScalarAI, InsertPt);
1750 if (ExtractedFuncRetVals.empty()) {
1756 return isa<ReturnInst>(Term) || isa<ResumeInst>(Term);
1762CallInst *CodeExtractor::emitReplacerCall(
1763 const ValueSet &inputs,
const ValueSet &outputs,
1764 const ValueSet &StructValues,
Function *newFunction,
1767 std::vector<Value *> &Reloads) {
1777 AllocationBlock ? AllocationBlock : &oldFunction->
getEntryBlock();
1784 std::vector<Value *> params;
1787 for (
Value *input : inputs) {
1788 if (StructValues.contains(input))
1791 params.push_back(input);
1795 std::vector<Value *> ReloadOutputs;
1796 for (
Value *output : outputs) {
1797 if (StructValues.contains(output))
1801 output->getType(),
DL.getAllocaAddrSpace(),
nullptr,
1803 params.push_back(alloca);
1804 ReloadOutputs.push_back(alloca);
1808 if (!StructValues.empty()) {
1811 if (ArgsInZeroAddressSpace &&
DL.getAllocaAddrSpace() != 0) {
1813 Struct, PointerType ::get(Context, 0),
"structArg.ascast");
1814 StructSpaceCast->insertAfter(
Struct->getIterator());
1815 params.push_back(StructSpaceCast);
1817 params.push_back(
Struct);
1820 unsigned AggIdx = 0;
1821 for (
Value *input : inputs) {
1822 if (!StructValues.contains(input))
1829 StructArgTy,
Struct,
Idx,
"gep_" + input->getName());
1830 GEP->insertInto(codeReplacer, codeReplacer->
end());
1839 newFunction, params, ExtractedFuncRetVals.size() > 1 ?
"targetBlock" :
"",
1843 unsigned ParamIdx = 0;
1844 unsigned AggIdx = 0;
1845 for (
auto input : inputs) {
1846 if (StructValues.contains(input)) {
1849 if (input->isSwiftError())
1866 for (
unsigned i = 0, e = outputs.size(), scalarIdx = 0; i != e; ++i) {
1867 Value *Output =
nullptr;
1868 if (StructValues.contains(outputs[i])) {
1874 GEP->insertInto(codeReplacer, codeReplacer->
end());
1878 Output = ReloadOutputs[scalarIdx];
1883 outputs[i]->
getName() +
".reload", codeReplacer);
1884 Reloads.push_back(
load);
1890 codeReplacer, 0, codeReplacer);
1891 for (
auto P :
enumerate(ExtractedFuncRetVals)) {
1893 size_t SuccNum =
P.index();
1900 Type *OldFnRetTy = TheSwitch->
getParent()->getParent()->getReturnType();
1901 switch (ExtractedFuncRetVals.size()) {
1909 }
else if (OldFnRetTy->
isVoidTy()) {
1964void CodeExtractor::insertReplacerCall(
1973 for (
auto &U :
Users)
1977 if (
I->isTerminator() &&
I->getFunction() == oldFunction &&
1978 !
Blocks.count(
I->getParent()))
1979 I->replaceUsesOfWith(header, codeReplacer);
1985 for (
BasicBlock *ExitBB : ExtractedFuncRetVals)
1986 for (
PHINode &PN : ExitBB->phis()) {
1987 Value *IncomingCodeReplacerVal =
nullptr;
1994 if (!IncomingCodeReplacerVal) {
1999 "PHI has two incompatbile incoming values from codeRepl");
2003 for (
unsigned i = 0, e = outputs.size(); i != e; ++i) {
2005 std::vector<User *>
Users(outputs[i]->user_begin(), outputs[i]->user_end());
2008 if (inst->
getParent()->getParent() == oldFunction)
2014 if (BFI && ExtractedFuncRetVals.size() > 1)
2015 calculateNewCallTerminatorWeights(codeReplacer, ExitWeights, BPI);
2022 auto *
I = dyn_cast_or_null<CallInst>(AssumeVH);
2027 if (
I->getFunction() != &OldFunc)
2034 auto *AffectedCI = dyn_cast_or_null<CallInst>(AffectedValVH);
2037 if (AffectedCI->getFunction() != &OldFunc)
2039 auto *AssumedInst = cast<Instruction>(AffectedCI->getOperand(0));
2040 if (AssumedInst->getFunction() != &OldFunc)
2048 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
Returns an iterator to the first instruction in this block that is not a PHINode instruction.
InstListType::const_iterator const_iterator
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.