72#define DEBUG_TYPE "code-extractor"
80 cl::desc(
"Aggregate arguments to code-extracted functions"));
85 bool AllowVarArgs,
bool AllowAlloca) {
95 while (!ToVisit.
empty()) {
97 if (!Visited.
insert(Curr).second)
105 for (
auto const &U : Curr->
operands()) {
123 if (
auto *UBB =
II->getUnwindDest())
124 if (!Result.count(UBB))
132 if (
auto *UBB = CSI->getUnwindDest())
133 if (!Result.count(UBB))
135 for (
const auto *HBB : CSI->handlers())
136 if (!Result.count(
const_cast<BasicBlock*
>(HBB)))
144 for (
const auto *U : CPI->users())
146 if (!Result.count(
const_cast<BasicBlock*
>(CRI->getParent())))
155 for (
const auto *U : CPI->users())
157 if (!Result.count(
const_cast<BasicBlock*
>(CRI->getParent())))
162 if (
auto *UBB = CRI->getUnwindDest())
163 if (!Result.count(UBB))
174 if (CI->isMustTailCall())
177 if (
const Function *
F = CI->getCalledFunction()) {
178 auto IID =
F->getIntrinsicID();
179 if (IID == Intrinsic::vastart) {
188 if (IID == Intrinsic::eh_typeid_for)
200 bool AllowVarArgs,
bool AllowAlloca) {
201 assert(!BBs.
empty() &&
"The set of blocks to extract must be non-empty");
211 if (!Result.insert(BB))
215 LLVM_DEBUG(
dbgs() <<
"Region front block: " << Result.front()->getName()
218 for (
auto *BB : Result) {
223 if (BB == Result.front()) {
225 LLVM_DEBUG(
dbgs() <<
"The first block cannot be an unwind block\n");
234 if (!Result.count(PBB)) {
235 LLVM_DEBUG(
dbgs() <<
"No blocks in this region may have entries from "
236 "outside the region except for the first block!\n"
237 <<
"Problematic source BB: " << BB->getName() <<
"\n"
238 <<
"Problematic destination BB: " << PBB->getName()
250 switch (TargetTriple.
getArch()) {
265 bool AllowVarArgs,
bool AllowAlloca,
266 BasicBlock *AllocationBlock, std::string Suffix,
267 bool ArgsInZeroAddressSpace)
269 BPI(BPI), AC(AC), AllocationBlock(AllocationBlock),
270 AllowVarArgs(AllowVarArgs),
272 Suffix(Suffix), ArgsInZeroAddressSpace(ArgsInZeroAddressSpace) {}
278 if (Blocks.
count(
I->getParent()))
289 if (!Blocks.
count(
I->getParent()))
299 if (Blocks.
count(Succ))
301 if (!CommonExitBlock) {
302 CommonExitBlock = Succ;
305 if (CommonExitBlock != Succ)
311 if (
any_of(Blocks, hasNonCommonExitSucc))
314 return CommonExitBlock;
321 Allocas.push_back(AI);
323 findSideEffectInfoForBlock(BB);
327void CodeExtractorAnalysisCache::findSideEffectInfoForBlock(
BasicBlock &BB) {
329 unsigned Opcode =
II.getOpcode();
330 Value *MemAddr =
nullptr;
332 case Instruction::Store:
333 case Instruction::Load: {
334 if (Opcode == Instruction::Store) {
336 MemAddr =
SI->getPointerOperand();
346 SideEffectingBlocks.insert(&BB);
349 BaseMemAddrs[&BB].insert(
Base);
357 SideEffectingBlocks.insert(&BB);
361 if (
II.mayHaveSideEffects()) {
362 SideEffectingBlocks.insert(&BB);
372 if (SideEffectingBlocks.count(&BB))
374 auto It = BaseMemAddrs.find(&BB);
375 if (It != BaseMemAddrs.end())
376 return It->second.count(Addr);
383 Function *Func = (*Blocks.begin())->getParent();
385 if (Blocks.count(&BB))
395 BasicBlock *SinglePredFromOutlineRegion =
nullptr;
396 assert(!Blocks.count(CommonExitBlock) &&
397 "Expect a block outside the region!");
399 if (!Blocks.count(Pred))
401 if (!SinglePredFromOutlineRegion) {
402 SinglePredFromOutlineRegion = Pred;
403 }
else if (SinglePredFromOutlineRegion != Pred) {
404 SinglePredFromOutlineRegion =
nullptr;
409 if (SinglePredFromOutlineRegion)
410 return SinglePredFromOutlineRegion;
416 while (
I != BB->end()) {
429 assert(!getFirstPHI(CommonExitBlock) &&
"Phi not expected");
437 if (Blocks.count(Pred))
439 Pred->getTerminator()->replaceUsesOfWith(CommonExitBlock, NewExitBlock);
442 Blocks.insert(CommonExitBlock);
443 return CommonExitBlock;
450CodeExtractor::LifetimeMarkerInfo
454 LifetimeMarkerInfo Info;
464 Info.LifeStart = IntrInst;
470 Info.LifeEnd = IntrInst;
479 if (!
Info.LifeStart || !
Info.LifeEnd)
485 if ((
Info.SinkLifeStart ||
Info.HoistLifeEnd) &&
490 if (
Info.HoistLifeEnd && !ExitBlock)
497 ValueSet &SinkCands, ValueSet &HoistCands,
499 Function *Func = (*Blocks.begin())->getParent();
502 auto moveOrIgnoreLifetimeMarkers =
503 [&](
const LifetimeMarkerInfo &LMI) ->
bool {
506 if (LMI.SinkLifeStart) {
509 SinkCands.
insert(LMI.LifeStart);
511 if (LMI.HoistLifeEnd) {
512 LLVM_DEBUG(
dbgs() <<
"Hoisting lifetime.end: " << *LMI.LifeEnd <<
"\n");
513 HoistCands.
insert(LMI.LifeEnd);
522 if (Blocks.count(BB))
531 LifetimeMarkerInfo MarkerInfo = getLifetimeMarkers(CEAC, AI, ExitBlock);
532 bool Moved = moveOrIgnoreLifetimeMarkers(MarkerInfo);
548 if (U->stripInBoundsConstantOffsets() != AI)
552 for (
User *BU : Bitcast->users()) {
561 << *Bitcast <<
" in out-of-region lifetime marker "
562 << *IntrInst <<
"\n");
563 LifetimeBitcastUsers.
push_back(IntrInst);
573 I->replaceUsesOfWith(
I->getOperand(1), CastI);
580 if (U->stripInBoundsConstantOffsets() == AI) {
582 LifetimeMarkerInfo LMI = getLifetimeMarkers(CEAC, Bitcast, ExitBlock);
598 if (Bitcasts.
empty())
601 LLVM_DEBUG(
dbgs() <<
"Sinking alloca (via bitcast): " << *AI <<
"\n");
603 for (
unsigned I = 0, E = Bitcasts.
size();
I != E; ++
I) {
605 const LifetimeMarkerInfo &LMI = BitcastLifetimeInfo[
I];
607 "Unsafe to sink bitcast without lifetime markers");
608 moveOrIgnoreLifetimeMarkers(LMI);
610 LLVM_DEBUG(
dbgs() <<
"Sinking bitcast-of-alloca: " << *BitcastAddr
612 SinkCands.
insert(BitcastAddr);
626 if (AllowVarArgs &&
F->getFunctionType()->isVarArg()) {
627 auto containsVarArgIntrinsic = [](
const Instruction &
I) {
629 if (
const Function *Callee = CI->getCalledFunction())
630 return Callee->getIntrinsicID() == Intrinsic::vastart ||
631 Callee->getIntrinsicID() == Intrinsic::vaend;
635 for (
auto &BB : *
F) {
636 if (Blocks.count(&BB))
650 bool IsSave =
II->getIntrinsicID() == Intrinsic::stacksave;
651 bool IsRestore =
II->getIntrinsicID() == Intrinsic::stackrestore;
652 if (IsSave &&
any_of(
II->users(), [&Blks = this->Blocks](
User *U) {
653 return !definedInRegion(Blks, U);
664 const ValueSet &SinkCands,
665 bool CollectGlobalInputs)
const {
670 for (
auto &OI :
II.operands()) {
672 if (!SinkCands.
count(V) &&
678 for (
User *U :
II.users())
690void CodeExtractor::severSplitPHINodesOfEntry(
BasicBlock *&Header) {
691 unsigned NumPredsFromRegion = 0;
692 unsigned NumPredsOutsideRegion = 0;
694 if (Header != &Header->getParent()->getEntryBlock()) {
703 ++NumPredsFromRegion;
705 ++NumPredsOutsideRegion;
709 if (NumPredsOutsideRegion <= 1)
return;
721 Blocks.remove(OldPred);
722 Blocks.insert(NewBB);
727 if (NumPredsFromRegion) {
767void CodeExtractor::severSplitPHINodesOfExits() {
768 for (BasicBlock *ExitBB : ExtractedFuncRetVals) {
771 for (PHINode &PN : ExitBB->phis()) {
773 SmallVector<unsigned, 2> IncomingVals;
781 if (IncomingVals.
size() <= 1)
788 ExitBB->getName() +
".split",
789 ExitBB->getParent(), ExitBB);
791 for (BasicBlock *PredBB : Preds)
792 if (Blocks.count(PredBB))
793 PredBB->getTerminator()->replaceUsesOfWith(ExitBB, NewBB);
795 Blocks.insert(NewBB);
802 for (
unsigned i : IncomingVals)
804 for (
unsigned i :
reverse(IncomingVals))
811void CodeExtractor::splitReturnBlocks() {
812 for (BasicBlock *
Block : Blocks)
815 Block->splitBasicBlock(RI->getIterator(),
Block->getName() +
".ret");
826 DT->changeImmediateDominator(
I, NewNode);
831Function *CodeExtractor::constructFunctionDeclaration(
832 const ValueSet &inputs,
const ValueSet &outputs,
BlockFrequency EntryFreq,
837 Function *oldFunction = Blocks.front()->getParent();
838 Module *
M = Blocks.front()->getModule();
841 std::vector<Type *> ParamTy;
842 std::vector<Type *> AggParamTy;
843 const DataLayout &
DL =
M->getDataLayout();
846 for (
Value *value : inputs) {
848 if (AggregateArgs && !ExcludeArgsFromAggregate.contains(value)) {
849 AggParamTy.push_back(value->getType());
850 StructValues.insert(value);
852 ParamTy.push_back(value->getType());
856 for (
Value *output : outputs) {
858 if (AggregateArgs && !ExcludeArgsFromAggregate.contains(output)) {
859 AggParamTy.push_back(output->getType());
860 StructValues.insert(output);
867 (ParamTy.size() + AggParamTy.size()) ==
868 (inputs.size() + outputs.size()) &&
869 "Number of scalar and aggregate params does not match inputs, outputs");
870 assert((StructValues.empty() || AggregateArgs) &&
871 "Expeced StructValues only with AggregateArgs set");
874 if (!AggParamTy.empty()) {
877 M->getContext(), ArgsInZeroAddressSpace ? 0 :
DL.getAllocaAddrSpace()));
880 Type *RetTy = getSwitchType();
882 dbgs() <<
"Function type: " << *RetTy <<
" f(";
883 for (
Type *i : ParamTy)
884 dbgs() << *i <<
", ";
889 RetTy, ParamTy, AllowVarArgs && oldFunction->
isVarArg());
907 for (
const auto &Attr : oldFunction->
getAttributes().getFnAttrs()) {
908 if (Attr.isStringAttribute()) {
909 if (Attr.getKindAsString() ==
"thunk")
912 switch (Attr.getKindAsEnum()) {
915 case Attribute::AllocSize:
916 case Attribute::Builtin:
917 case Attribute::Convergent:
918 case Attribute::JumpTable:
919 case Attribute::Naked:
920 case Attribute::NoBuiltin:
921 case Attribute::NoMerge:
922 case Attribute::NoReturn:
923 case Attribute::NoSync:
924 case Attribute::ReturnsTwice:
925 case Attribute::Speculatable:
926 case Attribute::StackAlignment:
927 case Attribute::WillReturn:
928 case Attribute::AllocKind:
929 case Attribute::PresplitCoroutine:
930 case Attribute::Memory:
931 case Attribute::NoFPClass:
932 case Attribute::CoroDestroyOnlyWhenComplete:
933 case Attribute::CoroElideSafe:
934 case Attribute::NoDivergenceSource:
935 case Attribute::NoCreateUndefOrPoison:
938 case Attribute::AlwaysInline:
939 case Attribute::Cold:
940 case Attribute::DisableSanitizerInstrumentation:
941 case Attribute::Flatten:
942 case Attribute::FnRetThunkExtern:
944 case Attribute::HybridPatchable:
945 case Attribute::NoRecurse:
946 case Attribute::InlineHint:
947 case Attribute::MinSize:
948 case Attribute::NoCallback:
949 case Attribute::NoDuplicate:
950 case Attribute::NoFree:
951 case Attribute::NoImplicitFloat:
952 case Attribute::NoInline:
953 case Attribute::NoOutline:
954 case Attribute::NonLazyBind:
955 case Attribute::NoRedZone:
956 case Attribute::NoUnwind:
957 case Attribute::NoSanitizeBounds:
958 case Attribute::NoSanitizeCoverage:
959 case Attribute::NullPointerIsValid:
960 case Attribute::OptimizeForDebugging:
961 case Attribute::OptForFuzzing:
962 case Attribute::OptimizeNone:
963 case Attribute::OptimizeForSize:
964 case Attribute::SafeStack:
965 case Attribute::ShadowCallStack:
966 case Attribute::SanitizeAddress:
967 case Attribute::SanitizeMemory:
968 case Attribute::SanitizeNumericalStability:
969 case Attribute::SanitizeThread:
970 case Attribute::SanitizeType:
971 case Attribute::SanitizeHWAddress:
972 case Attribute::SanitizeMemTag:
973 case Attribute::SanitizeRealtime:
974 case Attribute::SanitizeRealtimeBlocking:
975 case Attribute::SanitizeAllocToken:
976 case Attribute::SpeculativeLoadHardening:
977 case Attribute::StackProtect:
978 case Attribute::StackProtectReq:
979 case Attribute::StackProtectStrong:
980 case Attribute::StrictFP:
981 case Attribute::UWTable:
982 case Attribute::VScaleRange:
983 case Attribute::NoCfCheck:
984 case Attribute::MustProgress:
985 case Attribute::NoProfile:
986 case Attribute::SkipProfile:
987 case Attribute::DenormalFPEnv:
990 case Attribute::Alignment:
991 case Attribute::AllocatedPointer:
992 case Attribute::AllocAlign:
993 case Attribute::ByVal:
994 case Attribute::Captures:
995 case Attribute::Dereferenceable:
996 case Attribute::DereferenceableOrNull:
997 case Attribute::ElementType:
998 case Attribute::InAlloca:
999 case Attribute::InReg:
1000 case Attribute::Nest:
1001 case Attribute::NoAlias:
1002 case Attribute::NoUndef:
1003 case Attribute::NonNull:
1004 case Attribute::Preallocated:
1005 case Attribute::ReadNone:
1006 case Attribute::ReadOnly:
1007 case Attribute::Returned:
1008 case Attribute::SExt:
1009 case Attribute::StructRet:
1010 case Attribute::SwiftError:
1011 case Attribute::SwiftSelf:
1012 case Attribute::SwiftAsync:
1013 case Attribute::ZExt:
1014 case Attribute::ImmArg:
1015 case Attribute::ByRef:
1016 case Attribute::WriteOnly:
1017 case Attribute::Writable:
1018 case Attribute::DeadOnUnwind:
1019 case Attribute::Range:
1020 case Attribute::Initializes:
1021 case Attribute::NoExt:
1027 case Attribute::DeadOnReturn:
1040 for (
Value *input : inputs) {
1041 if (StructValues.contains(input))
1044 ScalarAI->
setName(input->getName());
1045 if (input->isSwiftError())
1047 Attribute::SwiftError);
1050 for (
Value *output : outputs) {
1051 if (StructValues.contains(output))
1054 ScalarAI->
setName(output->getName() +
".out");
1060 auto Count = BFI->getProfileCountFromFreq(EntryFreq);
1061 if (
Count.has_value())
1079 if (!
I.getDebugLoc())
1106 Value *Mem =
II->getOperand(0);
1110 if (
II->getIntrinsicID() == Intrinsic::lifetime_start)
1111 LifetimesStart.
insert(Mem);
1112 II->eraseFromParent();
1127 bool InsertBefore) {
1128 for (
Value *Mem : Objects) {
1131 "Input memory not defined in original function");
1139 Marker->insertBefore(Term->getIterator());
1143 if (!LifetimesStart.
empty()) {
1144 insertMarkers(Intrinsic::lifetime_start, LifetimesStart,
1148 if (!LifetimesEnd.
empty()) {
1149 insertMarkers(Intrinsic::lifetime_end, LifetimesEnd,
1154void CodeExtractor::moveCodeToFunction(
Function *newFunction) {
1155 auto newFuncIt = newFunction->
begin();
1156 for (BasicBlock *
Block : Blocks) {
1158 Block->removeFromParent();
1165 newFuncIt = newFunction->
insert(std::next(newFuncIt),
Block);
1169void CodeExtractor::calculateNewCallTerminatorWeights(
1173 using Distribution = BlockFrequencyInfoImplBase::Distribution;
1174 using BlockNode = BlockFrequencyInfoImplBase::BlockNode;
1181 Distribution BranchDist;
1188 BlockNode ExitNode(i);
1191 BranchDist.addExit(ExitNode, ExitFreq);
1197 if (BranchDist.Total == 0) {
1198 BPI->setEdgeProbability(CodeReplacer, EdgeProbabilities);
1203 BranchDist.normalize();
1206 for (
unsigned I = 0,
E = BranchDist.Weights.size();
I <
E; ++
I) {
1207 const auto &Weight = BranchDist.Weights[
I];
1210 BranchWeights[Weight.TargetNode.Index] = Weight.Amount;
1211 BranchProbability BP(Weight.Amount, BranchDist.Total);
1212 EdgeProbabilities[Weight.TargetNode.Index] = BP;
1214 BPI->setEdgeProbability(CodeReplacer, EdgeProbabilities);
1216 LLVMContext::MD_prof,
1217 MDBuilder(TI->
getContext()).createBranchWeights(BranchWeights));
1227 if (DVR->getFunction() != &
F)
1228 DVR->eraseFromParent();
1259 assert(OldSP->getUnit() &&
"Missing compile unit for subprogram");
1264 DISubprogram::SPFlagOptimized |
1265 DISubprogram::SPFlagLocalToUnit;
1268 0, SPType, 0, DINode::FlagZero, SPFlags);
1271 auto UpdateOrInsertDebugRecord = [&](
auto *DR,
Value *OldLoc,
Value *NewLoc,
1273 if (DR->getParent()->getParent() == &NewFunc) {
1274 DR->replaceVariableLocationOp(OldLoc, NewLoc);
1278 DIB.
insertDeclare(NewLoc, DR->getVariable(), Expr, DR->getDebugLoc(),
1283 NewLoc, DR->getVariable(), Expr, DR->getDebugLoc(),
1294 for (
auto *DVR : DPUsers)
1295 UpdateOrInsertDebugRecord(DVR,
Input, NewVal, Expr, DVR->isDbgDeclare());
1298 auto IsInvalidLocation = [&NewFunc](
Value *Location) {
1306 return Arg->getParent() != &NewFunc;
1323 DINode *&NewVar = RemappedMetadata[OldVar];
1326 *OldVar->getScope(), *NewSP, Ctx, Cache);
1328 NewScope, OldVar->
getName(), OldVar->getFile(), OldVar->getLine(),
1329 OldVar->getType(),
false, DINode::FlagZero,
1330 OldVar->getAlignInBits());
1335 auto UpdateDbgLabel = [&](
auto *LabelRecord) {
1338 if (LabelRecord->getDebugLoc().getInlinedAt())
1340 DILabel *OldLabel = LabelRecord->getLabel();
1341 DINode *&NewLabel = RemappedMetadata[OldLabel];
1344 *OldLabel->
getScope(), *NewSP, Ctx, Cache);
1353 auto UpdateDbgRecordsOnInst = [&](
Instruction &
I) ->
void {
1354 for (
DbgRecord &DR :
I.getDbgRecordRange()) {
1356 UpdateDbgLabel(DLR);
1382 UpdateDbgRecordsOnInst(
I);
1384 for (
auto *DVR : DVRsToDelete)
1385 DVR->getMarker()->MarkedInstr->dropOneDbgRecord(DVR);
1397 *NewSP, Ctx, Cache));
1400 auto updateLoopInfoLoc = [&Ctx, &Cache, NewSP](
Metadata *MD) ->
Metadata * {
1416 ValueSet Inputs, Outputs;
1422 ValueSet &inputs, ValueSet &outputs) {
1431 normalizeCFGForExtraction(header);
1439 AC->unregisterAssumption(AI);
1440 AI->eraseFromParent();
1445 ValueSet SinkingCands, HoistingCands;
1447 findAllocas(CEAC, SinkingCands, HoistingCands, CommonExit);
1457 ValueSet LifetimesStart;
1460 if (!HoistingCands.
empty()) {
1463 for (
auto *
II : HoistingCands)
1465 computeExtractedFuncRetVals();
1475 assert(BPI &&
"Both BPI and BFI are required to preserve profile info");
1477 if (Blocks.count(Pred))
1480 BFI->getBlockFreq(Pred) * BPI->getEdgeProbability(Pred, header);
1483 for (
BasicBlock *Succ : ExtractedFuncRetVals) {
1485 if (!Blocks.count(
Block))
1490 BF += BFI->getBlockFreq(
Block) * BPI->getEdgeProbability(
Block, Succ);
1498 while (ReplIP && Blocks.count(ReplIP))
1502 std::string SuffixToUse =
1507 ValueSet StructValues;
1509 Function *newFunction = constructFunctionDeclaration(
1510 inputs, outputs, EntryFreq, oldFunction->
getName() +
"." + SuffixToUse,
1511 StructValues, StructTy);
1514 emitFunctionBody(inputs, outputs, StructValues, newFunction, StructTy, header,
1515 SinkingCands, NewValues);
1517 std::vector<Value *> Reloads;
1518 CallInst *TheCall = emitReplacerCall(
1519 inputs, outputs, StructValues, newFunction, StructTy, oldFunction, ReplIP,
1520 EntryFreq, LifetimesStart.
getArrayRef(), Reloads);
1522 insertReplacerCall(oldFunction, header, TheCall->
getParent(), outputs,
1523 Reloads, ExitWeights);
1537void CodeExtractor::normalizeCFGForExtraction(
BasicBlock *&header) {
1540 splitReturnBlocks();
1543 severSplitPHINodesOfEntry(header);
1549 computeExtractedFuncRetVals();
1550 severSplitPHINodesOfExits();
1553void CodeExtractor::computeExtractedFuncRetVals() {
1554 ExtractedFuncRetVals.clear();
1559 if (Blocks.count(Succ))
1562 bool IsNew = ExitBlocks.
insert(Succ).second;
1564 ExtractedFuncRetVals.push_back(Succ);
1569Type *CodeExtractor::getSwitchType() {
1572 assert(ExtractedFuncRetVals.size() < 0xffff &&
1573 "too many exit blocks for switch");
1574 switch (ExtractedFuncRetVals.size()) {
1586void CodeExtractor::emitFunctionBody(
1587 const ValueSet &inputs,
const ValueSet &outputs,
1588 const ValueSet &StructValues,
Function *newFunction,
1602 for (
auto *
II : SinkingCands) {
1608 for (
auto *
II : SinkingCands) {
1615 Argument *AggArg = StructValues.empty()
1621 for (
unsigned i = 0, e = inputs.size(), aggIdx = 0; i != e; ++i) {
1623 if (StructValues.contains(inputs[i])) {
1628 StructArgTy, AggArg, Idx,
"gep_" + inputs[i]->
getName(), newFuncRoot);
1631 "loadgep_" + inputs[i]->getName(), newFuncRoot);
1644 unsigned AlignmentValue;
1645 const Triple &TargetTriple =
1653 inputs[i]->stripPointerCasts()->getPointerAlignment(
DL).value();
1655 AlignmentValue = inputs[i]->getPointerAlignment(
DL).value();
1658 LLVMContext::MD_align,
1661 MDB.createConstant(ConstantInt::get(
1664 RewriteVal = LoadGEP;
1667 RewriteVal = &*ScalarAI++;
1672 moveCodeToFunction(newFunction);
1674 for (
unsigned i = 0, e = inputs.size(); i != e; ++i) {
1675 Value *RewriteVal = NewValues[i];
1677 std::vector<User *>
Users(inputs[i]->user_begin(), inputs[i]->user_end());
1680 if (Blocks.count(inst->getParent()))
1681 inst->replaceUsesOfWith(inputs[i], RewriteVal);
1689 std::map<BasicBlock *, BasicBlock *> ExitBlockMap;
1693 for (
auto P :
enumerate(ExtractedFuncRetVals)) {
1695 size_t SuccNum =
P.index();
1699 ExitBlockMap[OldTarget] = NewTarget;
1701 Value *brVal =
nullptr;
1702 Type *RetTy = getSwitchType();
1703 assert(ExtractedFuncRetVals.size() < 0xffff &&
1704 "too many exit blocks for switch");
1705 switch (ExtractedFuncRetVals.size()) {
1711 brVal = ConstantInt::get(RetTy, !SuccNum);
1714 brVal = ConstantInt::get(RetTy, SuccNum);
1721 for (BasicBlock *
Block : Blocks) {
1728 BasicBlock *NewTarget = ExitBlockMap[OldTarget];
1729 assert(NewTarget &&
"Unknown target block!");
1753 unsigned AggIdx = 0;
1755 for (
Value *Input : inputs) {
1756 if (StructValues.contains(Input))
1762 for (
Value *Output : outputs) {
1769 InsertPt = InvokeI->getNormalDest()->getFirstInsertionPt();
1771 InsertPt =
Phi->getParent()->getFirstInsertionPt();
1773 InsertPt = std::next(OutI->getIterator());
1776 if (StructValues.contains(Output))
1783 assert((InsertPt->getFunction() == newFunction ||
1784 Blocks.count(InsertPt->getParent())) &&
1785 "InsertPt should be in new function");
1787 if (StructValues.contains(Output)) {
1788 assert(AggArg &&
"Number of aggregate output arguments should match "
1789 "the number of defined values");
1794 StructArgTy, AggArg, Idx,
"gep_" + Output->getName(), InsertPt);
1795 new StoreInst(Output,
GEP, InsertPt);
1799 "Number of scalar output arguments should match "
1800 "the number of defined values");
1801 new StoreInst(Output, &*ScalarAI, InsertPt);
1806 if (ExtractedFuncRetVals.empty()) {
1810 if (
none_of(Blocks, [](
const BasicBlock *BB) {
1818CallInst *CodeExtractor::emitReplacerCall(
1819 const ValueSet &inputs,
const ValueSet &outputs,
1820 const ValueSet &StructValues,
Function *newFunction,
1823 std::vector<Value *> &Reloads) {
1826 const DataLayout &
DL =
M->getDataLayout();
1831 if (AllocationBlock)
1832 assert(AllocationBlock->getParent() == oldFunction &&
1833 "AllocationBlock is not in the same function");
1835 AllocationBlock ? AllocationBlock : &oldFunction->
getEntryBlock();
1839 BFI->setBlockFreq(codeReplacer, EntryFreq);
1841 std::vector<Value *> params;
1844 for (
Value *input : inputs) {
1845 if (StructValues.contains(input))
1848 params.push_back(input);
1852 std::vector<Value *> ReloadOutputs;
1853 for (
Value *output : outputs) {
1854 if (StructValues.contains(output))
1857 AllocaInst *alloca =
new AllocaInst(
1858 output->getType(),
DL.getAllocaAddrSpace(),
nullptr,
1860 params.push_back(alloca);
1861 ReloadOutputs.push_back(alloca);
1864 AllocaInst *
Struct =
nullptr;
1865 if (!StructValues.empty()) {
1866 Struct =
new AllocaInst(StructArgTy,
DL.getAllocaAddrSpace(),
nullptr,
1868 if (ArgsInZeroAddressSpace &&
DL.getAllocaAddrSpace() != 0) {
1869 auto *StructSpaceCast =
new AddrSpaceCastInst(
1870 Struct, PointerType ::get(
Context, 0),
"structArg.ascast");
1871 StructSpaceCast->insertAfter(
Struct->getIterator());
1872 params.push_back(StructSpaceCast);
1874 params.push_back(Struct);
1877 unsigned AggIdx = 0;
1878 for (
Value *input : inputs) {
1879 if (!StructValues.contains(input))
1886 StructArgTy, Struct, Idx,
"gep_" + input->getName());
1887 GEP->insertInto(codeReplacer, codeReplacer->
end());
1888 new StoreInst(input,
GEP, codeReplacer);
1896 newFunction, params, ExtractedFuncRetVals.size() > 1 ?
"targetBlock" :
"",
1900 unsigned ParamIdx = 0;
1901 unsigned AggIdx = 0;
1902 for (
auto input : inputs) {
1903 if (StructValues.contains(input)) {
1906 if (input->isSwiftError())
1923 for (
unsigned i = 0, e = outputs.size(), scalarIdx = 0; i != e; ++i) {
1924 Value *Output =
nullptr;
1925 if (StructValues.contains(outputs[i])) {
1930 StructArgTy, Struct, Idx,
"gep_reload_" + outputs[i]->
getName());
1931 GEP->insertInto(codeReplacer, codeReplacer->
end());
1935 Output = ReloadOutputs[scalarIdx];
1939 new LoadInst(outputs[i]->
getType(), Output,
1940 outputs[i]->
getName() +
".reload", codeReplacer);
1941 Reloads.push_back(
load);
1945 SwitchInst *TheSwitch =
1947 codeReplacer, 0, codeReplacer);
1948 for (
auto P :
enumerate(ExtractedFuncRetVals)) {
1950 size_t SuccNum =
P.index();
1957 Type *OldFnRetTy = TheSwitch->
getParent()->getParent()->getReturnType();
1958 switch (ExtractedFuncRetVals.size()) {
1966 }
else if (OldFnRetTy->
isVoidTy()) {
2021void CodeExtractor::insertReplacerCall(
2030 for (
auto &U :
Users)
2034 if (
I->isTerminator() &&
I->getFunction() == oldFunction &&
2035 !Blocks.count(
I->getParent()))
2036 I->replaceUsesOfWith(header, codeReplacer);
2042 for (BasicBlock *ExitBB : ExtractedFuncRetVals)
2043 for (PHINode &PN : ExitBB->phis()) {
2044 Value *IncomingCodeReplacerVal =
nullptr;
2051 if (!IncomingCodeReplacerVal) {
2056 "PHI has two incompatbile incoming values from codeRepl");
2060 for (
unsigned i = 0, e = outputs.size(); i != e; ++i) {
2062 std::vector<User *>
Users(outputs[i]->user_begin(), outputs[i]->user_end());
2063 for (User *U :
Users) {
2065 if (inst->
getParent()->getParent() == oldFunction)
2071 if (BFI && ExtractedFuncRetVals.size() > 1)
2072 calculateNewCallTerminatorWeights(codeReplacer, ExitWeights, BPI);
2078 for (
auto AssumeVH : AC->assumptions()) {
2084 if (
I->getFunction() != &OldFunc)
2090 for (
auto AffectedValVH : AC->assumptionsFor(
I->getOperand(0))) {
2094 if (AffectedCI->getFunction() != &OldFunc)
2097 if (AssumedInst->getFunction() != &OldFunc)
2105 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
Machine Check Debug Module
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)
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.
@ 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 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 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...
Analysis providing branch probability information.
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 LLVM_ABI CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
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 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 DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, BasicBlock *InsertAtEnd)
Insert a new llvm.dbg.declare intrinsic call.
LLVM_ABI DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, InsertPosition InsertPt)
Insert a new llvm.dbg.value intrinsic call.
LLVM_ABI DITypeArray getOrCreateTypeArray(ArrayRef< Metadata * > Elements)
Get a DITypeArray, create one if required.
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.
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
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
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.
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 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.
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.
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).
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.
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 PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type 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 count(const_arg_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.
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
str - 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 *IfTrue, 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.
iterator_range< user_iterator > users()
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 * > Tys={})
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.
FunctionAddr VTableAddr Value
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...
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)
FunctionAddr VTableAddr Count
Function::ProfileCount ProfileCount
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.
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.