70#define DEBUG_TYPE "code-extractor"
78 cl::desc(
"Aggregate arguments to code-extracted functions"));
83 bool AllowVarArgs,
bool AllowAlloca) {
93 while (!ToVisit.
empty()) {
95 if (!Visited.
insert(Curr).second)
103 for (
auto const &U : Curr->
operands()) {
121 if (
auto *UBB =
II->getUnwindDest())
122 if (!Result.count(UBB))
130 if (
auto *UBB = CSI->getUnwindDest())
131 if (!Result.count(UBB))
133 for (
const auto *HBB : CSI->handlers())
134 if (!Result.count(
const_cast<BasicBlock*
>(HBB)))
142 for (
const auto *U : CPI->users())
144 if (!Result.count(
const_cast<BasicBlock*
>(CRI->getParent())))
153 for (
const auto *U : CPI->users())
155 if (!Result.count(
const_cast<BasicBlock*
>(CRI->getParent())))
160 if (
auto *UBB = CRI->getUnwindDest())
161 if (!Result.count(UBB))
178 if (CI->isMustTailCall())
181 if (
const Function *
F = CI->getCalledFunction()) {
182 auto IID =
F->getIntrinsicID();
183 if (IID == Intrinsic::vastart) {
192 if (IID == Intrinsic::eh_typeid_for)
204 bool AllowVarArgs,
bool AllowAlloca) {
205 assert(!BBs.
empty() &&
"The set of blocks to extract must be non-empty");
215 if (!Result.insert(BB))
219 LLVM_DEBUG(
dbgs() <<
"Region front block: " << Result.front()->getName()
222 for (
auto *BB : Result) {
227 if (BB == Result.front()) {
229 LLVM_DEBUG(
dbgs() <<
"The first block cannot be an unwind block\n");
238 if (!Result.count(PBB)) {
239 LLVM_DEBUG(
dbgs() <<
"No blocks in this region may have entries from "
240 "outside the region except for the first block!\n"
241 <<
"Problematic source BB: " << BB->getName() <<
"\n"
242 <<
"Problematic destination BB: " << PBB->getName()
254 switch (TargetTriple.
getArch()) {
269 bool AllowVarArgs,
bool AllowAlloca,
272 std::string Suffix,
bool ArgsInZeroAddressSpace,
273 bool VoidReturnWithSingleOutput)
275 BPI(BPI), AC(AC), AllocationBlock(AllocationBlock),
276 DeallocationBlocks(DeallocationBlocks), AllowVarArgs(AllowVarArgs),
278 Suffix(Suffix), ArgsInZeroAddressSpace(ArgsInZeroAddressSpace),
279 VoidReturnWithSingleOutput(VoidReturnWithSingleOutput) {}
285 if (Blocks.
count(
I->getParent()))
296 if (!Blocks.
count(
I->getParent()))
306 if (Blocks.
count(Succ))
308 if (!CommonExitBlock) {
309 CommonExitBlock = Succ;
312 if (CommonExitBlock != Succ)
318 if (
any_of(Blocks, hasNonCommonExitSucc))
321 return CommonExitBlock;
328 Allocas.push_back(AI);
330 findSideEffectInfoForBlock(BB);
334void CodeExtractorAnalysisCache::findSideEffectInfoForBlock(
BasicBlock &BB) {
336 unsigned Opcode =
II.getOpcode();
337 Value *MemAddr =
nullptr;
339 case Instruction::Store:
340 case Instruction::Load: {
341 if (Opcode == Instruction::Store) {
343 MemAddr =
SI->getPointerOperand();
353 SideEffectingBlocks.insert(&BB);
356 BaseMemAddrs[&BB].insert(
Base);
364 SideEffectingBlocks.insert(&BB);
368 if (
II.mayHaveSideEffects()) {
369 SideEffectingBlocks.insert(&BB);
379 if (SideEffectingBlocks.count(&BB))
381 auto It = BaseMemAddrs.find(&BB);
382 if (It != BaseMemAddrs.end())
383 return It->second.count(Addr);
390 Function *Func = (*Blocks.begin())->getParent();
392 if (Blocks.count(&BB))
402 BasicBlock *SinglePredFromOutlineRegion =
nullptr;
403 assert(!Blocks.count(CommonExitBlock) &&
404 "Expect a block outside the region!");
406 if (!Blocks.count(Pred))
408 if (!SinglePredFromOutlineRegion) {
409 SinglePredFromOutlineRegion = Pred;
410 }
else if (SinglePredFromOutlineRegion != Pred) {
411 SinglePredFromOutlineRegion =
nullptr;
416 if (SinglePredFromOutlineRegion)
417 return SinglePredFromOutlineRegion;
423 while (
I != BB->end()) {
436 assert(!getFirstPHI(CommonExitBlock) &&
"Phi not expected");
444 if (Blocks.count(Pred))
446 Pred->getTerminator()->replaceUsesOfWith(CommonExitBlock, NewExitBlock);
449 Blocks.insert(CommonExitBlock);
450 return CommonExitBlock;
461 new AllocaInst(VarType,
DL.getAllocaAddrSpace(),
nullptr, Name, AllocaIP);
463 if (CastedAlloc && ArgsInZeroAddressSpace &&
DL.getAllocaAddrSpace() != 0) {
466 (*CastedAlloc)->insertAfter(Alloca->
getIterator());
481CodeExtractor::LifetimeMarkerInfo
485 LifetimeMarkerInfo Info;
495 Info.LifeStart = IntrInst;
501 Info.LifeEnd = IntrInst;
510 if (!
Info.LifeStart || !
Info.LifeEnd)
516 if ((
Info.SinkLifeStart ||
Info.HoistLifeEnd) &&
521 if (
Info.HoistLifeEnd && !ExitBlock)
528 ValueSet &SinkCands, ValueSet &HoistCands,
530 Function *Func = (*Blocks.begin())->getParent();
533 auto moveOrIgnoreLifetimeMarkers =
534 [&](
const LifetimeMarkerInfo &LMI) ->
bool {
537 if (LMI.SinkLifeStart) {
540 SinkCands.
insert(LMI.LifeStart);
542 if (LMI.HoistLifeEnd) {
543 LLVM_DEBUG(
dbgs() <<
"Hoisting lifetime.end: " << *LMI.LifeEnd <<
"\n");
544 HoistCands.
insert(LMI.LifeEnd);
553 if (Blocks.count(BB))
562 LifetimeMarkerInfo MarkerInfo = getLifetimeMarkers(CEAC, AI, ExitBlock);
563 bool Moved = moveOrIgnoreLifetimeMarkers(MarkerInfo);
580 if (AllowVarArgs &&
F->getFunctionType()->isVarArg()) {
581 auto containsVarArgIntrinsic = [](
const Instruction &
I) {
583 if (
const Function *Callee = CI->getCalledFunction())
584 return Callee->getIntrinsicID() == Intrinsic::vastart ||
585 Callee->getIntrinsicID() == Intrinsic::vaend;
589 for (
auto &BB : *
F) {
590 if (Blocks.count(&BB))
604 bool IsSave =
II->getIntrinsicID() == Intrinsic::stacksave;
605 bool IsRestore =
II->getIntrinsicID() == Intrinsic::stackrestore;
606 if (IsSave &&
any_of(
II->users(), [&Blks = this->Blocks](
User *U) {
607 return !definedInRegion(Blks, U);
618 const ValueSet &SinkCands,
619 bool CollectGlobalInputs) {
624 for (
auto &OI :
II.operands()) {
626 if (!SinkCands.
count(V) &&
632 for (
User *U :
II.users())
642 FuncRetVal =
nullptr;
643 if (!VoidReturnWithSingleOutput && !AggregateArgs && Outputs.
size() == 1 &&
645 FuncRetVal = Outputs[0];
653void CodeExtractor::severSplitPHINodesOfEntry(
BasicBlock *&Header) {
654 unsigned NumPredsFromRegion = 0;
655 unsigned NumPredsOutsideRegion = 0;
657 if (Header != &Header->getParent()->getEntryBlock()) {
666 ++NumPredsFromRegion;
668 ++NumPredsOutsideRegion;
672 if (NumPredsOutsideRegion <= 1)
return;
684 Blocks.remove(OldPred);
685 Blocks.insert(NewBB);
690 if (NumPredsFromRegion) {
730void CodeExtractor::severSplitPHINodesOfExits() {
731 for (BasicBlock *ExitBB : ExtractedFuncRetVals) {
734 for (PHINode &PN : ExitBB->phis()) {
736 SmallVector<unsigned, 2> IncomingVals;
744 if (IncomingVals.
size() <= 1)
751 ExitBB->getName() +
".split",
752 ExitBB->getParent(), ExitBB);
754 for (BasicBlock *PredBB : Preds)
755 if (Blocks.count(PredBB))
756 PredBB->getTerminator()->replaceUsesOfWith(ExitBB, NewBB);
758 Blocks.insert(NewBB);
765 for (
unsigned i : IncomingVals)
767 for (
unsigned i :
reverse(IncomingVals))
774void CodeExtractor::splitReturnBlocks() {
775 for (BasicBlock *
Block : Blocks)
778 Block->splitBasicBlock(RI->getIterator(),
Block->getName() +
".ret");
789 DT->changeImmediateDominator(
I, NewNode);
794Function *CodeExtractor::constructFunctionDeclaration(
795 const ValueSet &inputs,
const ValueSet &outputs,
BlockFrequency EntryFreq,
800 Function *oldFunction = Blocks.front()->getParent();
801 Module *
M = Blocks.front()->getModule();
804 std::vector<Type *> ParamTy;
805 std::vector<Type *> AggParamTy;
806 const DataLayout &
DL =
M->getDataLayout();
809 for (
Value *value : inputs) {
811 if (AggregateArgs && !ExcludeArgsFromAggregate.contains(value)) {
812 AggParamTy.push_back(value->getType());
813 StructValues.insert(value);
815 ParamTy.push_back(value->getType());
819 for (
Value *output : outputs) {
821 if (AggregateArgs && !ExcludeArgsFromAggregate.contains(output)) {
822 AggParamTy.push_back(output->getType());
823 StructValues.insert(output);
830 (ParamTy.size() + AggParamTy.size()) ==
831 (inputs.size() + outputs.size()) &&
832 "Number of scalar and aggregate params does not match inputs, outputs");
833 assert((StructValues.empty() || AggregateArgs) &&
834 "Expeced StructValues only with AggregateArgs set");
837 if (!AggParamTy.empty()) {
840 M->getContext(), ArgsInZeroAddressSpace ? 0 :
DL.getAllocaAddrSpace()));
843 Type *RetTy = FuncRetVal ? FuncRetVal->getType() : getSwitchType();
845 dbgs() <<
"Function type: " << *RetTy <<
" f(";
846 for (
Type *i : ParamTy)
847 dbgs() << *i <<
", ";
852 RetTy, ParamTy, AllowVarArgs && oldFunction->
isVarArg());
870 for (
const auto &Attr : oldFunction->
getAttributes().getFnAttrs()) {
871 if (Attr.isStringAttribute()) {
872 if (Attr.getKindAsString() ==
"thunk")
875 switch (Attr.getKindAsEnum()) {
878 case Attribute::AllocSize:
879 case Attribute::Builtin:
880 case Attribute::Convergent:
881 case Attribute::JumpTable:
882 case Attribute::Naked:
883 case Attribute::NoBuiltin:
884 case Attribute::NoMerge:
885 case Attribute::NoReturn:
886 case Attribute::NoSync:
887 case Attribute::ReturnsTwice:
888 case Attribute::Speculatable:
889 case Attribute::StackAlignment:
890 case Attribute::WillReturn:
891 case Attribute::AllocKind:
892 case Attribute::PresplitCoroutine:
893 case Attribute::Memory:
894 case Attribute::NoFPClass:
895 case Attribute::CoroDestroyOnlyWhenComplete:
896 case Attribute::CoroElideSafe:
897 case Attribute::NoDivergenceSource:
898 case Attribute::NoCreateUndefOrPoison:
901 case Attribute::AlwaysInline:
902 case Attribute::Cold:
903 case Attribute::DisableSanitizerInstrumentation:
904 case Attribute::Flatten:
905 case Attribute::FnRetThunkExtern:
907 case Attribute::HybridPatchable:
908 case Attribute::NoRecurse:
909 case Attribute::InlineHint:
910 case Attribute::MinSize:
911 case Attribute::NoCallback:
912 case Attribute::NoDuplicate:
913 case Attribute::NoFree:
914 case Attribute::NoImplicitFloat:
915 case Attribute::NoInline:
916 case Attribute::NoIPA:
917 case Attribute::NoOutline:
918 case Attribute::NonLazyBind:
919 case Attribute::NoRedZone:
920 case Attribute::NoUnwind:
921 case Attribute::NoSanitizeBounds:
922 case Attribute::NoSanitizeCoverage:
923 case Attribute::NullPointerIsValid:
924 case Attribute::OptimizeForDebugging:
925 case Attribute::OptForFuzzing:
926 case Attribute::OptimizeNone:
927 case Attribute::OptimizeForSize:
928 case Attribute::SafeStack:
929 case Attribute::ShadowCallStack:
930 case Attribute::SanitizeAddress:
931 case Attribute::SanitizeMemory:
932 case Attribute::SanitizeNumericalStability:
933 case Attribute::SanitizeThread:
934 case Attribute::SanitizeConcurrency:
935 case Attribute::SanitizeType:
936 case Attribute::SanitizeHWAddress:
937 case Attribute::SanitizeMemTag:
938 case Attribute::SanitizeRealtime:
939 case Attribute::SanitizeRealtimeBlocking:
940 case Attribute::SanitizeAllocToken:
941 case Attribute::SpeculativeLoadHardening:
942 case Attribute::StackProtect:
943 case Attribute::StackProtectReq:
944 case Attribute::StackProtectStrong:
945 case Attribute::StrictFP:
946 case Attribute::UWTable:
947 case Attribute::VScaleRange:
948 case Attribute::NoCfCheck:
949 case Attribute::MustProgress:
950 case Attribute::NoProfile:
951 case Attribute::SkipProfile:
952 case Attribute::DenormalFPEnv:
955 case Attribute::Alignment:
956 case Attribute::AllocatedPointer:
957 case Attribute::AllocAlign:
958 case Attribute::ByVal:
959 case Attribute::Captures:
960 case Attribute::Dereferenceable:
961 case Attribute::DereferenceableOrNull:
962 case Attribute::ElementType:
963 case Attribute::InAlloca:
964 case Attribute::InReg:
965 case Attribute::Nest:
966 case Attribute::NoAlias:
967 case Attribute::NoUndef:
968 case Attribute::NonNull:
969 case Attribute::Preallocated:
970 case Attribute::ReadNone:
971 case Attribute::ReadOnly:
972 case Attribute::Returned:
973 case Attribute::SExt:
974 case Attribute::StructRet:
975 case Attribute::SwiftError:
976 case Attribute::SwiftSelf:
977 case Attribute::SwiftAsync:
978 case Attribute::ZExt:
979 case Attribute::ImmArg:
980 case Attribute::ByRef:
981 case Attribute::WriteOnly:
982 case Attribute::Writable:
983 case Attribute::DeadOnUnwind:
984 case Attribute::Range:
985 case Attribute::Initializes:
986 case Attribute::NoExt:
987 case Attribute::NoFreeObj:
993 case Attribute::DeadOnReturn:
1006 for (
Value *input : inputs) {
1007 if (StructValues.contains(input))
1010 ScalarAI->
setName(input->getName());
1011 if (input->isSwiftError())
1013 Attribute::SwiftError);
1016 for (
Value *output : outputs) {
1017 if (StructValues.contains(output))
1020 ScalarAI->
setName(output->getName() +
".out");
1026 auto Count = BFI->getProfileCountFromFreq(EntryFreq);
1027 if (
Count.has_value())
1044 if (!
I.getDebugLoc())
1071 Value *Mem =
II->getOperand(0);
1075 if (
II->getIntrinsicID() == Intrinsic::lifetime_start)
1076 LifetimesStart.
insert(Mem);
1077 II->eraseFromParent();
1092 bool InsertBefore) {
1093 for (
Value *Mem : Objects) {
1096 "Input memory not defined in original function");
1104 Marker->insertBefore(Term->getIterator());
1108 if (!LifetimesStart.
empty()) {
1109 insertMarkers(Intrinsic::lifetime_start, LifetimesStart,
1113 if (!LifetimesEnd.
empty()) {
1114 insertMarkers(Intrinsic::lifetime_end, LifetimesEnd,
1119void CodeExtractor::moveCodeToFunction(
Function *newFunction) {
1120 auto newFuncIt = newFunction->
begin();
1121 for (BasicBlock *
Block : Blocks) {
1123 Block->removeFromParent();
1130 newFuncIt = newFunction->
insert(std::next(newFuncIt),
Block);
1134void CodeExtractor::calculateNewCallTerminatorWeights(
1138 using Distribution = BlockFrequencyInfoImplBase::Distribution;
1139 using BlockNode = BlockFrequencyInfoImplBase::BlockNode;
1146 Distribution BranchDist;
1153 BlockNode ExitNode(i);
1156 BranchDist.addExit(ExitNode, ExitFreq);
1162 if (BranchDist.Total == 0) {
1163 BPI->setEdgeProbability(CodeReplacer, EdgeProbabilities);
1168 BranchDist.normalize();
1171 for (
unsigned I = 0,
E = BranchDist.Weights.size();
I <
E; ++
I) {
1172 const auto &Weight = BranchDist.Weights[
I];
1175 BranchWeights[Weight.TargetNode.Index] = Weight.Amount;
1176 BranchProbability BP(Weight.Amount, BranchDist.Total);
1177 EdgeProbabilities[Weight.TargetNode.Index] = BP;
1179 BPI->setEdgeProbability(CodeReplacer, EdgeProbabilities);
1181 LLVMContext::MD_prof,
1182 MDBuilder(TI->
getContext()).createBranchWeights(BranchWeights));
1192 if (DVR->getFunction() != &
F)
1193 DVR->eraseFromParent();
1224 assert(OldSP->getUnit() &&
"Missing compile unit for subprogram");
1229 DISubprogram::SPFlagOptimized |
1230 DISubprogram::SPFlagLocalToUnit;
1233 0, SPType, 0, DINode::FlagZero, SPFlags);
1236 auto UpdateOrInsertDebugRecord = [&](
auto *DR,
Value *OldLoc,
Value *NewLoc,
1238 if (DR->getParent()->getParent() == &NewFunc) {
1239 DR->replaceVariableLocationOp(OldLoc, NewLoc);
1243 DIB.
insertDeclare(NewLoc, DR->getVariable(), Expr, DR->getDebugLoc(),
1247 DIB.
insertDbgValue(NewLoc, DR->getVariable(), Expr, DR->getDebugLoc(),
1257 for (
auto *DVR : DPUsers) {
1258 DIExpression *Expr = DVR->getNumVariableLocationOps() == 1
1259 ? DVR->getExpression()
1261 UpdateOrInsertDebugRecord(DVR,
Input, NewVal, Expr, DVR->isDbgDeclare());
1265 auto IsInvalidLocation = [&NewFunc](
Value *Location) {
1273 return Arg->getParent() != &NewFunc;
1290 DINode *&NewVar = RemappedMetadata[OldVar];
1293 *OldVar->getScope(), *NewSP, Ctx, Cache);
1295 NewScope, OldVar->
getName(), OldVar->getFile(), OldVar->getLine(),
1296 OldVar->getType(),
false, DINode::FlagZero,
1297 OldVar->getAlignInBits());
1302 auto UpdateDbgLabel = [&](
auto *LabelRecord) {
1305 if (LabelRecord->getDebugLoc().getInlinedAt())
1307 DILabel *OldLabel = LabelRecord->getLabel();
1308 DINode *&NewLabel = RemappedMetadata[OldLabel];
1311 *OldLabel->
getScope(), *NewSP, Ctx, Cache);
1320 auto UpdateDbgRecordsOnInst = [&](
Instruction &
I) ->
void {
1321 for (
DbgRecord &DR :
I.getDbgRecordRange()) {
1323 UpdateDbgLabel(DLR);
1349 UpdateDbgRecordsOnInst(
I);
1351 for (
auto *DVR : DVRsToDelete)
1352 DVR->getMarker()->MarkedInstr->dropOneDbgRecord(DVR);
1364 *NewSP, Ctx, Cache));
1367 auto updateLoopInfoLoc = [&Ctx, &Cache, NewSP](
Metadata *MD) ->
Metadata * {
1383 ValueSet Inputs, Outputs;
1389 ValueSet &inputs, ValueSet &outputs) {
1398 normalizeCFGForExtraction(header);
1406 AC->unregisterAssumption(AI);
1407 AI->eraseFromParent();
1412 ValueSet SinkingCands, HoistingCands;
1414 findAllocas(CEAC, SinkingCands, HoistingCands, CommonExit);
1424 ValueSet LifetimesStart;
1427 if (!HoistingCands.
empty()) {
1430 for (
auto *
II : HoistingCands)
1432 computeExtractedFuncRetVals();
1442 assert(BPI &&
"Both BPI and BFI are required to preserve profile info");
1444 if (Blocks.count(Pred))
1447 BFI->getBlockFreq(Pred) * BPI->getEdgeProbability(Pred, header);
1450 for (
BasicBlock *Succ : ExtractedFuncRetVals) {
1452 if (!Blocks.count(
Block))
1457 BF += BFI->getBlockFreq(
Block) * BPI->getEdgeProbability(
Block, Succ);
1465 while (ReplIP && Blocks.count(ReplIP))
1469 std::string SuffixToUse =
1474 ValueSet StructValues;
1476 Function *newFunction = constructFunctionDeclaration(
1477 inputs, outputs, EntryFreq, oldFunction->
getName() +
"." + SuffixToUse,
1478 StructValues, StructTy);
1481 emitFunctionBody(inputs, outputs, StructValues, newFunction, StructTy, header,
1482 SinkingCands, NewValues);
1484 std::vector<Value *> Reloads;
1485 CallInst *TheCall = emitReplacerCall(
1486 inputs, outputs, StructValues, newFunction, StructTy, oldFunction, ReplIP,
1487 EntryFreq, LifetimesStart.
getArrayRef(), Reloads);
1489 insertReplacerCall(oldFunction, header, TheCall, outputs, Reloads,
1504void CodeExtractor::normalizeCFGForExtraction(
BasicBlock *&header) {
1507 splitReturnBlocks();
1510 severSplitPHINodesOfEntry(header);
1516 computeExtractedFuncRetVals();
1517 severSplitPHINodesOfExits();
1520void CodeExtractor::computeExtractedFuncRetVals() {
1521 ExtractedFuncRetVals.clear();
1526 if (Blocks.count(Succ))
1529 bool IsNew = ExitBlocks.
insert(Succ).second;
1531 ExtractedFuncRetVals.push_back(Succ);
1536Type *CodeExtractor::getSwitchType() {
1539 assert(ExtractedFuncRetVals.size() < 0xffff &&
1540 "too many exit blocks for switch");
1541 switch (ExtractedFuncRetVals.size()) {
1553void CodeExtractor::emitFunctionBody(
1554 const ValueSet &inputs,
const ValueSet &outputs,
1555 const ValueSet &StructValues,
Function *newFunction,
1569 for (
auto *
II : SinkingCands) {
1575 for (
auto *
II : SinkingCands) {
1582 Argument *AggArg = StructValues.empty()
1588 for (
unsigned i = 0, e = inputs.size(), aggIdx = 0; i != e; ++i) {
1590 if (StructValues.contains(inputs[i])) {
1595 StructArgTy, AggArg, Idx,
"gep_" + inputs[i]->
getName(), newFuncRoot);
1598 "loadgep_" + inputs[i]->getName(), newFuncRoot);
1611 unsigned AlignmentValue;
1612 const Triple &TargetTriple =
1620 inputs[i]->stripPointerCasts()->getPointerAlignment(
DL).value();
1622 AlignmentValue = inputs[i]->getPointerAlignment(
DL).value();
1625 LLVMContext::MD_align,
1628 MDB.createConstant(ConstantInt::get(
1631 RewriteVal = LoadGEP;
1634 RewriteVal = &*ScalarAI++;
1639 moveCodeToFunction(newFunction);
1641 for (
unsigned i = 0, e = inputs.size(); i != e; ++i) {
1642 Value *RewriteVal = NewValues[i];
1644 std::vector<User *>
Users(inputs[i]->user_begin(), inputs[i]->user_end());
1647 if (Blocks.count(inst->getParent()))
1648 inst->replaceUsesOfWith(inputs[i], RewriteVal);
1656 std::map<BasicBlock *, BasicBlock *> ExitBlockMap;
1660 for (
auto P :
enumerate(ExtractedFuncRetVals)) {
1662 size_t SuccNum =
P.index();
1666 ExitBlockMap[OldTarget] = NewTarget;
1668 Value *brVal =
nullptr;
1669 Type *RetTy = FuncRetVal ? FuncRetVal->getType() : getSwitchType();
1670 assert(ExtractedFuncRetVals.size() < 0xffff &&
1671 "too many exit blocks for switch");
1672 switch (ExtractedFuncRetVals.size()) {
1681 brVal = ConstantInt::get(RetTy, !SuccNum);
1684 brVal = ConstantInt::get(RetTy, SuccNum);
1691 for (BasicBlock *
Block : Blocks) {
1698 BasicBlock *NewTarget = ExitBlockMap[OldTarget];
1699 assert(NewTarget &&
"Unknown target block!");
1723 unsigned AggIdx = 0;
1725 for (
Value *Input : inputs) {
1726 if (StructValues.contains(Input))
1732 for (
Value *Output : outputs) {
1739 InsertPt = InvokeI->getNormalDest()->getFirstInsertionPt();
1741 InsertPt =
Phi->getParent()->getFirstInsertionPt();
1743 InsertPt = std::next(OutI->getIterator());
1746 if (StructValues.contains(Output))
1753 assert((InsertPt->getFunction() == newFunction ||
1754 Blocks.count(InsertPt->getParent())) &&
1755 "InsertPt should be in new function");
1757 if (StructValues.contains(Output)) {
1758 assert(AggArg &&
"Number of aggregate output arguments should match "
1759 "the number of defined values");
1764 StructArgTy, AggArg, Idx,
"gep_" +
Output->getName(), InsertPt);
1765 new StoreInst(Output,
GEP, InsertPt);
1769 "Number of scalar output arguments should match "
1770 "the number of defined values");
1771 new StoreInst(Output, &*ScalarAI, InsertPt);
1776 if (ExtractedFuncRetVals.empty()) {
1780 if (
none_of(Blocks, [](
const BasicBlock *BB) {
1788CallInst *CodeExtractor::emitReplacerCall(
1789 const ValueSet &inputs,
const ValueSet &outputs,
1790 const ValueSet &StructValues,
Function *newFunction,
1793 std::vector<Value *> &Reloads) {
1800 if (AllocationBlock)
1801 assert(AllocationBlock->getParent() == oldFunction &&
1802 "AllocationBlock is not in the same function");
1804 AllocationBlock ? AllocationBlock : &oldFunction->
getEntryBlock();
1815 BFI->setBlockFreq(codeReplacer, EntryFreq);
1817 std::vector<Value *> params;
1820 for (
Value *input : inputs) {
1821 if (StructValues.contains(input))
1824 params.push_back(input);
1828 std::vector<Value *> ReloadOutputs;
1829 for (
Value *output : outputs) {
1830 if (StructValues.contains(output))
1836 params.push_back(OutAlloc);
1837 ReloadOutputs.push_back(OutAlloc);
1841 if (!StructValues.empty()) {
1842 AddrSpaceCastInst *StructSpaceCast =
nullptr;
1844 "structArg", &StructSpaceCast);
1845 if (StructSpaceCast)
1846 params.push_back(StructSpaceCast);
1848 params.push_back(Struct);
1850 unsigned AggIdx = 0;
1851 for (
Value *input : inputs) {
1852 if (!StructValues.contains(input))
1859 StructArgTy, Struct, Idx,
"gep_" + input->getName());
1860 GEP->insertInto(codeReplacer, codeReplacer->
end());
1861 new StoreInst(input,
GEP, codeReplacer);
1869 newFunction, params, ExtractedFuncRetVals.size() > 1 ?
"targetBlock" :
"",
1873 unsigned ParamIdx = 0;
1874 unsigned AggIdx = 0;
1875 for (
auto input : inputs) {
1876 if (StructValues.contains(input)) {
1879 if (input->isSwiftError())
1892 for (
unsigned i = 0, e = outputs.size(), scalarIdx = 0; i != e; ++i) {
1894 if (StructValues.contains(outputs[i])) {
1899 StructArgTy, Struct, Idx,
"gep_reload_" + outputs[i]->
getName());
1900 GEP->insertInto(codeReplacer, codeReplacer->
end());
1904 Output = ReloadOutputs[scalarIdx];
1908 new LoadInst(outputs[i]->
getType(), Output,
1909 outputs[i]->
getName() +
".reload", codeReplacer);
1910 Reloads.push_back(
load);
1914 SwitchInst *TheSwitch =
1916 codeReplacer, 0, codeReplacer);
1917 for (
auto P :
enumerate(ExtractedFuncRetVals)) {
1919 size_t SuccNum =
P.index();
1926 Type *OldFnRetTy = TheSwitch->
getParent()->getParent()->getReturnType();
1927 switch (ExtractedFuncRetVals.size()) {
1935 }
else if (OldFnRetTy->
isVoidTy()) {
1990 for (
Value *Output : outputs) {
1991 if (!StructValues.contains(Output))
1999 if (DeallocationBlocks.empty()) {
2000 deallocVars(codeReplacer->
end());
2002 for (BasicBlock *DeallocationBlock : DeallocationBlocks)
2003 deallocVars(DeallocationBlock->getFirstInsertionPt());
2009void CodeExtractor::insertReplacerCall(
2019 for (
auto &U :
Users)
2023 if (
I->isTerminator() &&
I->getFunction() == oldFunction &&
2024 !Blocks.count(
I->getParent()))
2025 I->replaceUsesOfWith(header, codeReplacer);
2031 for (BasicBlock *ExitBB : ExtractedFuncRetVals)
2032 for (PHINode &PN : ExitBB->phis()) {
2033 Value *IncomingCodeReplacerVal =
nullptr;
2040 if (!IncomingCodeReplacerVal) {
2045 "PHI has two incompatbile incoming values from codeRepl");
2049 for (
unsigned i = 0, e = outputs.size(); i != e; ++i) {
2051 std::vector<User *>
Users(outputs[i]->user_begin(), outputs[i]->user_end());
2052 for (User *U :
Users) {
2054 if (inst->
getParent()->getParent() == oldFunction)
2060 FuncRetVal->replaceUsesWithIf(ReplacerCall, [&](Use &U) {
2065 if (BFI && ExtractedFuncRetVals.size() > 1)
2066 calculateNewCallTerminatorWeights(codeReplacer, ExitWeights, BPI);
2072 for (
auto AssumeVH : AC->assumptions()) {
2078 if (
I->getFunction() != &OldFunc)
2084 for (
auto AffectedValVH : AC->assumptionsFor(
I->getOperand(0))) {
2088 if (AffectedCI->getFunction() != &OldFunc)
2091 if (AssumedInst->getFunction() != &OldFunc)
2099 ExcludeArgsFromAggregate.insert(Arg);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the DenseMap class.
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)
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)
static Function * getFunction(FunctionType *Ty, const Twine &Name, Module *M)
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.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
Check if the array is empty.
A cache of @llvm.assume calls within a function.
@ 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.
LLVM_ABI const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
LLVM_ABI BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="")
Split the basic block into two basic blocks at the specified instruction.
const Function * getParent() const
Return the enclosing method, or null if none.
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches,...
LLVM_ABI 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.
LLVM_ABI const CallInst * getTerminatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize prior to the terminating return in...
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this basic block belongs to.
InstListType::iterator iterator
Instruction iterators...
LLVM_ABI LLVMContext & getContext() const
Get the context in which this basic block lives.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Analysis providing branch probability information.
static constexpr BranchProbability getUnknown()
static constexpr 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)
static CondBrInst * Create(Value *Cond, BasicBlock *IfTrue, BasicBlock *IfFalse, InsertPosition InsertBefore=nullptr)
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
LLVM_ABI void finalizeSubprogram(DISubprogram *SP)
Finalize a specific subprogram - no new variables may be added to this subprogram afterwards.
LLVM_ABI DISubroutineType * createSubroutineType(DITypeArray ParameterTypes, DINode::DIFlags Flags=DINode::FlagZero, unsigned CC=0)
Create subroutine type.
LLVM_ABI DbgRecord * insertDbgValue(llvm::Value *Val, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, InsertPosition InsertPt)
Insert a new dbg_value record.
LLVM_ABI 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="", bool UseKeyInstructions=false)
Create a new descriptor for the specified subprogram.
LLVM_ABI DITypeArray getOrCreateTypeArray(ArrayRef< Metadata * > Elements)
Get a DITypeArray, create one if required.
LLVM_ABI DbgRecord * insertDeclare(Value *Storage, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, BasicBlock *InsertAtEnd)
Insert a new dbg_declare record.
LLVM_ABI DIExpression * createExpression(ArrayRef< uint64_t > Addr={})
Create a new descriptor for the specified variable which has a complex address expression for its add...
LLVM_ABI 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
bool isArtificial() const
unsigned getColumn() const
DILocalScope * getScope() const
Get the local scope for this label.
std::optional< unsigned > getCoroSuspendIdx() const
static LLVM_ABI 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.
LLVM_ABI StringRef getName() const
Subprogram description. Uses SubclassData1.
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
Record of a variable value-assignment, aka a non instruction representation of the dbg....
LLVM_ABI Value * getAddress() const
void setVariable(DILocalVariable *NewVar)
DILocalVariable * getVariable() const
LLVM_ABI iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
static LLVM_ABI 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.
LLVM_ABI DILocation * getInlinedAt() const
ValueT lookup(const_arg_type_t< KeyT > Val) const
Return the entry for the specified key, or a default constructed value if no such entry exists.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
LLVM_ABI bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
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 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.
const Function & getFunction() const
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.
void setEntryCount(uint64_t Count, const DenseSet< GlobalValue::GUID > *Imports=nullptr)
Set the entry count for this function.
bool doesNotReturn() const
Determine if the function cannot return.
Argument * getArg(unsigned i) const
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
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).
BasicBlock::iterator InsertPoint
InsertPoint - A saved insertion point.
LLVM_ABI bool isLifetimeStartOrEnd() const LLVM_READONLY
Return true if the instruction is a llvm.lifetime.start or llvm.lifetime.end marker.
LLVM_ABI unsigned getNumSuccessors() const LLVM_READONLY
Return the number of successors that this instruction has.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
LLVM_ABI void moveBefore(InstListType::iterator InsertPos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
LLVM_ABI void insertBefore(InstListType::iterator InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified position.
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
LLVM_ABI BasicBlock * getSuccessor(unsigned Idx) const LLVM_READONLY
Return the specified successor. This instruction must be a terminator.
iterator_range< user_iterator > users()
LLVM_ABI 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.
LLVM_ABI void setSuccessor(unsigned Idx, BasicBlock *BB)
Update the specified successor to point at the provided block.
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()
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
LLVM_ABI 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.
const Triple & getTargetTriple() const
Get the target triple which is a string describing the target host.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
LLVM_ABI void removeIncomingValueIf(function_ref< bool(unsigned)> Predicate, bool DeletePHIIfEmpty=true)
Remove all incoming values for which the predicate returns true.
void setIncomingBlock(unsigned i, BasicBlock *BB)
LLVM_ABI 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 LLVM_ABI PointerType * get(LLVMContext &C, unsigned AddressSpace)
This constructs an opaque pointer to an object in a numbered address space.
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 size() const
Determine the number of elements in the SetVector.
size_type count(const_arg_type key) const
Count the number of elements of a given key in the SetVector.
void clear()
Completely clear 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.
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.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
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
Get the contents as an std::string.
Class to represent struct types.
static LLVM_ABI 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)
LLVM_ABI void addCase(ConstantInt *OnVal, BasicBlock *Dest)
Add an entry to the switch instruction.
CaseIteratorImpl< CaseHandle > CaseIt
void setDefaultDest(BasicBlock *DefaultCase)
Value * getCondition() const
LLVM_ABI CaseIt removeCase(CaseIt I)
This method removes the specified case and its successor from the switch instruction.
Triple - Helper class for working with autoconf configuration names.
ArchType getArch() const
Get the parsed architecture type of this triple.
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 LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
bool isPointerTy() const
True if this is an instance of PointerType.
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
static LLVM_ABI IntegerType * getInt16Ty(LLVMContext &C)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
bool isVoidTy() const
Return true if this is 'void'.
static UncondBrInst * Create(BasicBlock *Target, InsertPosition InsertBefore=nullptr)
LLVM_ABI 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()
LLVM_ABI void setName(const Twine &Name)
Change the name of the value.
LLVM_ABI const Value * stripInBoundsConstantOffsets() const
Strip off pointer casts and all-constant inbounds GEPs.
LLVM_ABI 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.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
LLVM_ABI 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.
@ BasicBlock
Various leaf nodes.
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > OverloadTys={})
Look up the Function declaration of the intrinsic id in the Module M.
LLVM_ABI void remapAssignID(DenseMap< DIAssignID *, DIAssignID * > &Map, Instruction &I)
Replace DIAssignID uses and attachments with IDs from Map.
NodeAddr< PhiNode * > Phi
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
detail::zippy< detail::zip_first, T, U, Args... > zip_equal(T &&t, U &&u, Args &&...args)
zip iterator that assumes that all iteratees have the same length.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
LLVM_ABI bool stripDebugInfo(Function &F)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
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...
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
DomTreeNodeBase< BasicBlock > DomTreeNode
auto dyn_cast_or_null(const Y &Val)
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)
LLVM_ABI 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.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI BasicBlock * SplitBlock(BasicBlock *Old, BasicBlock::iterator SplitPt, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="")
Split the specified block at the specified instruction.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
auto predecessors(const MachineBasicBlock *BB)
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
LLVM_ABI void updateLoopMetadataDebugLocations(Instruction &I, function_ref< Metadata *(Metadata *)> Updater)
Update the debug locations contained within the MD_loop metadata attached to the instruction I,...
LLVM_ABI void findDbgUsers(Value *V, SmallVectorImpl< DbgVariableRecord * > &DbgVariableRecords)
Finds the debug info records describing a value.