71#define DEBUG_TYPE "code-extractor"
79 cl::desc(
"Aggregate arguments to code-extracted functions"));
84 bool AllowVarArgs,
bool AllowAlloca) {
94 while (!ToVisit.
empty()) {
96 if (!Visited.
insert(Curr).second)
104 for (
auto const &U : Curr->
operands()) {
122 if (
auto *UBB =
II->getUnwindDest())
123 if (!Result.count(UBB))
131 if (
auto *UBB = CSI->getUnwindDest())
132 if (!Result.count(UBB))
134 for (
const auto *HBB : CSI->handlers())
135 if (!Result.count(
const_cast<BasicBlock*
>(HBB)))
143 for (
const auto *U : CPI->users())
145 if (!Result.count(
const_cast<BasicBlock*
>(CRI->getParent())))
154 for (
const auto *U : CPI->users())
156 if (!Result.count(
const_cast<BasicBlock*
>(CRI->getParent())))
161 if (
auto *UBB = CRI->getUnwindDest())
162 if (!Result.count(UBB))
173 if (CI->isMustTailCall())
176 if (
const Function *
F = CI->getCalledFunction()) {
177 auto IID =
F->getIntrinsicID();
178 if (IID == Intrinsic::vastart) {
187 if (IID == Intrinsic::eh_typeid_for)
199 bool AllowVarArgs,
bool AllowAlloca) {
200 assert(!BBs.
empty() &&
"The set of blocks to extract must be non-empty");
210 if (!Result.insert(BB))
214 LLVM_DEBUG(
dbgs() <<
"Region front block: " << Result.front()->getName()
217 for (
auto *BB : Result) {
222 if (BB == Result.front()) {
224 LLVM_DEBUG(
dbgs() <<
"The first block cannot be an unwind block\n");
233 if (!Result.count(PBB)) {
234 LLVM_DEBUG(
dbgs() <<
"No blocks in this region may have entries from "
235 "outside the region except for the first block!\n"
236 <<
"Problematic source BB: " << BB->getName() <<
"\n"
237 <<
"Problematic destination BB: " << PBB->getName()
249 switch (TargetTriple.
getArch()) {
264 bool AllowVarArgs,
bool AllowAlloca,
267 std::string Suffix,
bool ArgsInZeroAddressSpace,
268 bool VoidReturnWithSingleOutput)
270 BPI(BPI), AC(AC), AllocationBlock(AllocationBlock),
271 DeallocationBlocks(DeallocationBlocks), AllowVarArgs(AllowVarArgs),
273 Suffix(Suffix), ArgsInZeroAddressSpace(ArgsInZeroAddressSpace),
274 VoidReturnWithSingleOutput(VoidReturnWithSingleOutput) {}
280 if (Blocks.
count(
I->getParent()))
291 if (!Blocks.
count(
I->getParent()))
301 if (Blocks.
count(Succ))
303 if (!CommonExitBlock) {
304 CommonExitBlock = Succ;
307 if (CommonExitBlock != Succ)
313 if (
any_of(Blocks, hasNonCommonExitSucc))
316 return CommonExitBlock;
323 Allocas.push_back(AI);
325 findSideEffectInfoForBlock(BB);
329void CodeExtractorAnalysisCache::findSideEffectInfoForBlock(
BasicBlock &BB) {
331 unsigned Opcode =
II.getOpcode();
332 Value *MemAddr =
nullptr;
334 case Instruction::Store:
335 case Instruction::Load: {
336 if (Opcode == Instruction::Store) {
338 MemAddr =
SI->getPointerOperand();
348 SideEffectingBlocks.insert(&BB);
351 BaseMemAddrs[&BB].insert(
Base);
359 SideEffectingBlocks.insert(&BB);
363 if (
II.mayHaveSideEffects()) {
364 SideEffectingBlocks.insert(&BB);
374 if (SideEffectingBlocks.count(&BB))
376 auto It = BaseMemAddrs.find(&BB);
377 if (It != BaseMemAddrs.end())
378 return It->second.count(Addr);
385 Function *Func = (*Blocks.begin())->getParent();
387 if (Blocks.count(&BB))
397 BasicBlock *SinglePredFromOutlineRegion =
nullptr;
398 assert(!Blocks.count(CommonExitBlock) &&
399 "Expect a block outside the region!");
401 if (!Blocks.count(Pred))
403 if (!SinglePredFromOutlineRegion) {
404 SinglePredFromOutlineRegion = Pred;
405 }
else if (SinglePredFromOutlineRegion != Pred) {
406 SinglePredFromOutlineRegion =
nullptr;
411 if (SinglePredFromOutlineRegion)
412 return SinglePredFromOutlineRegion;
418 while (
I != BB->end()) {
431 assert(!getFirstPHI(CommonExitBlock) &&
"Phi not expected");
439 if (Blocks.count(Pred))
441 Pred->getTerminator()->replaceUsesOfWith(CommonExitBlock, NewExitBlock);
444 Blocks.insert(CommonExitBlock);
445 return CommonExitBlock;
453 nullptr, Name, AllocaIP.
getPoint());
455 if (CastedAlloc && ArgsInZeroAddressSpace &&
DL.getAllocaAddrSpace() != 0) {
459 (*CastedAlloc)->insertAfter(Alloca->
getIterator());
474CodeExtractor::LifetimeMarkerInfo
478 LifetimeMarkerInfo Info;
488 Info.LifeStart = IntrInst;
494 Info.LifeEnd = IntrInst;
503 if (!
Info.LifeStart || !
Info.LifeEnd)
509 if ((
Info.SinkLifeStart ||
Info.HoistLifeEnd) &&
514 if (
Info.HoistLifeEnd && !ExitBlock)
521 ValueSet &SinkCands, ValueSet &HoistCands,
523 Function *Func = (*Blocks.begin())->getParent();
526 auto moveOrIgnoreLifetimeMarkers =
527 [&](
const LifetimeMarkerInfo &LMI) ->
bool {
530 if (LMI.SinkLifeStart) {
533 SinkCands.
insert(LMI.LifeStart);
535 if (LMI.HoistLifeEnd) {
536 LLVM_DEBUG(
dbgs() <<
"Hoisting lifetime.end: " << *LMI.LifeEnd <<
"\n");
537 HoistCands.
insert(LMI.LifeEnd);
546 if (Blocks.count(BB))
555 LifetimeMarkerInfo MarkerInfo = getLifetimeMarkers(CEAC, AI, ExitBlock);
556 bool Moved = moveOrIgnoreLifetimeMarkers(MarkerInfo);
572 if (U->stripInBoundsConstantOffsets() != AI)
576 for (
User *BU : Bitcast->users()) {
585 << *Bitcast <<
" in out-of-region lifetime marker "
586 << *IntrInst <<
"\n");
587 LifetimeBitcastUsers.
push_back(IntrInst);
597 I->replaceUsesOfWith(
I->getOperand(1), CastI);
604 if (U->stripInBoundsConstantOffsets() == AI) {
606 LifetimeMarkerInfo LMI = getLifetimeMarkers(CEAC, Bitcast, ExitBlock);
622 if (Bitcasts.
empty())
625 LLVM_DEBUG(
dbgs() <<
"Sinking alloca (via bitcast): " << *AI <<
"\n");
627 for (
unsigned I = 0, E = Bitcasts.
size();
I != E; ++
I) {
629 const LifetimeMarkerInfo &LMI = BitcastLifetimeInfo[
I];
631 "Unsafe to sink bitcast without lifetime markers");
632 moveOrIgnoreLifetimeMarkers(LMI);
634 LLVM_DEBUG(
dbgs() <<
"Sinking bitcast-of-alloca: " << *BitcastAddr
636 SinkCands.
insert(BitcastAddr);
650 if (AllowVarArgs &&
F->getFunctionType()->isVarArg()) {
651 auto containsVarArgIntrinsic = [](
const Instruction &
I) {
653 if (
const Function *Callee = CI->getCalledFunction())
654 return Callee->getIntrinsicID() == Intrinsic::vastart ||
655 Callee->getIntrinsicID() == Intrinsic::vaend;
659 for (
auto &BB : *
F) {
660 if (Blocks.count(&BB))
674 bool IsSave =
II->getIntrinsicID() == Intrinsic::stacksave;
675 bool IsRestore =
II->getIntrinsicID() == Intrinsic::stackrestore;
676 if (IsSave &&
any_of(
II->users(), [&Blks = this->Blocks](
User *U) {
677 return !definedInRegion(Blks, U);
688 const ValueSet &SinkCands,
689 bool CollectGlobalInputs) {
694 for (
auto &OI :
II.operands()) {
696 if (!SinkCands.
count(V) &&
702 for (
User *U :
II.users())
712 FuncRetVal =
nullptr;
713 if (!VoidReturnWithSingleOutput && !AggregateArgs && Outputs.
size() == 1 &&
715 FuncRetVal = Outputs[0];
723void CodeExtractor::severSplitPHINodesOfEntry(
BasicBlock *&Header) {
724 unsigned NumPredsFromRegion = 0;
725 unsigned NumPredsOutsideRegion = 0;
727 if (Header != &Header->getParent()->getEntryBlock()) {
736 ++NumPredsFromRegion;
738 ++NumPredsOutsideRegion;
742 if (NumPredsOutsideRegion <= 1)
return;
754 Blocks.remove(OldPred);
755 Blocks.insert(NewBB);
760 if (NumPredsFromRegion) {
800void CodeExtractor::severSplitPHINodesOfExits() {
801 for (BasicBlock *ExitBB : ExtractedFuncRetVals) {
804 for (PHINode &PN : ExitBB->phis()) {
806 SmallVector<unsigned, 2> IncomingVals;
814 if (IncomingVals.
size() <= 1)
821 ExitBB->getName() +
".split",
822 ExitBB->getParent(), ExitBB);
824 for (BasicBlock *PredBB : Preds)
825 if (Blocks.count(PredBB))
826 PredBB->getTerminator()->replaceUsesOfWith(ExitBB, NewBB);
828 Blocks.insert(NewBB);
835 for (
unsigned i : IncomingVals)
837 for (
unsigned i :
reverse(IncomingVals))
844void CodeExtractor::splitReturnBlocks() {
845 for (BasicBlock *
Block : Blocks)
848 Block->splitBasicBlock(RI->getIterator(),
Block->getName() +
".ret");
859 DT->changeImmediateDominator(
I, NewNode);
864Function *CodeExtractor::constructFunctionDeclaration(
865 const ValueSet &inputs,
const ValueSet &outputs,
BlockFrequency EntryFreq,
870 Function *oldFunction = Blocks.front()->getParent();
871 Module *
M = Blocks.front()->getModule();
874 std::vector<Type *> ParamTy;
875 std::vector<Type *> AggParamTy;
876 const DataLayout &
DL =
M->getDataLayout();
879 for (
Value *value : inputs) {
881 if (AggregateArgs && !ExcludeArgsFromAggregate.contains(value)) {
882 AggParamTy.push_back(value->getType());
883 StructValues.insert(value);
885 ParamTy.push_back(value->getType());
889 for (
Value *output : outputs) {
891 if (AggregateArgs && !ExcludeArgsFromAggregate.contains(output)) {
892 AggParamTy.push_back(output->getType());
893 StructValues.insert(output);
900 (ParamTy.size() + AggParamTy.size()) ==
901 (inputs.size() + outputs.size()) &&
902 "Number of scalar and aggregate params does not match inputs, outputs");
903 assert((StructValues.empty() || AggregateArgs) &&
904 "Expeced StructValues only with AggregateArgs set");
907 if (!AggParamTy.empty()) {
910 M->getContext(), ArgsInZeroAddressSpace ? 0 :
DL.getAllocaAddrSpace()));
913 Type *RetTy = FuncRetVal ? FuncRetVal->getType() : getSwitchType();
915 dbgs() <<
"Function type: " << *RetTy <<
" f(";
916 for (
Type *i : ParamTy)
917 dbgs() << *i <<
", ";
922 RetTy, ParamTy, AllowVarArgs && oldFunction->
isVarArg());
940 for (
const auto &Attr : oldFunction->
getAttributes().getFnAttrs()) {
941 if (Attr.isStringAttribute()) {
942 if (Attr.getKindAsString() ==
"thunk")
945 switch (Attr.getKindAsEnum()) {
948 case Attribute::AllocSize:
949 case Attribute::Builtin:
950 case Attribute::Convergent:
951 case Attribute::JumpTable:
952 case Attribute::Naked:
953 case Attribute::NoBuiltin:
954 case Attribute::NoMerge:
955 case Attribute::NoReturn:
956 case Attribute::NoSync:
957 case Attribute::ReturnsTwice:
958 case Attribute::Speculatable:
959 case Attribute::StackAlignment:
960 case Attribute::WillReturn:
961 case Attribute::AllocKind:
962 case Attribute::PresplitCoroutine:
963 case Attribute::Memory:
964 case Attribute::NoFPClass:
965 case Attribute::CoroDestroyOnlyWhenComplete:
966 case Attribute::CoroElideSafe:
967 case Attribute::NoDivergenceSource:
968 case Attribute::NoCreateUndefOrPoison:
971 case Attribute::AlwaysInline:
972 case Attribute::Cold:
973 case Attribute::DisableSanitizerInstrumentation:
974 case Attribute::Flatten:
975 case Attribute::FnRetThunkExtern:
977 case Attribute::HybridPatchable:
978 case Attribute::NoRecurse:
979 case Attribute::InlineHint:
980 case Attribute::MinSize:
981 case Attribute::NoCallback:
982 case Attribute::NoDuplicate:
983 case Attribute::NoFree:
984 case Attribute::NoImplicitFloat:
985 case Attribute::NoInline:
986 case Attribute::NoOutline:
987 case Attribute::NonLazyBind:
988 case Attribute::NoRedZone:
989 case Attribute::NoUnwind:
990 case Attribute::NoSanitizeBounds:
991 case Attribute::NoSanitizeCoverage:
992 case Attribute::NullPointerIsValid:
993 case Attribute::OptimizeForDebugging:
994 case Attribute::OptForFuzzing:
995 case Attribute::OptimizeNone:
996 case Attribute::OptimizeForSize:
997 case Attribute::SafeStack:
998 case Attribute::ShadowCallStack:
999 case Attribute::SanitizeAddress:
1000 case Attribute::SanitizeMemory:
1001 case Attribute::SanitizeNumericalStability:
1002 case Attribute::SanitizeThread:
1003 case Attribute::SanitizeType:
1004 case Attribute::SanitizeHWAddress:
1005 case Attribute::SanitizeMemTag:
1006 case Attribute::SanitizeRealtime:
1007 case Attribute::SanitizeRealtimeBlocking:
1008 case Attribute::SanitizeAllocToken:
1009 case Attribute::SpeculativeLoadHardening:
1010 case Attribute::StackProtect:
1011 case Attribute::StackProtectReq:
1012 case Attribute::StackProtectStrong:
1013 case Attribute::StrictFP:
1014 case Attribute::UWTable:
1015 case Attribute::VScaleRange:
1016 case Attribute::NoCfCheck:
1017 case Attribute::MustProgress:
1018 case Attribute::NoProfile:
1019 case Attribute::SkipProfile:
1020 case Attribute::DenormalFPEnv:
1023 case Attribute::Alignment:
1024 case Attribute::AllocatedPointer:
1025 case Attribute::AllocAlign:
1026 case Attribute::ByVal:
1027 case Attribute::Captures:
1028 case Attribute::Dereferenceable:
1029 case Attribute::DereferenceableOrNull:
1030 case Attribute::ElementType:
1031 case Attribute::InAlloca:
1032 case Attribute::InReg:
1033 case Attribute::Nest:
1034 case Attribute::NoAlias:
1035 case Attribute::NoUndef:
1036 case Attribute::NonNull:
1037 case Attribute::Preallocated:
1038 case Attribute::ReadNone:
1039 case Attribute::ReadOnly:
1040 case Attribute::Returned:
1041 case Attribute::SExt:
1042 case Attribute::StructRet:
1043 case Attribute::SwiftError:
1044 case Attribute::SwiftSelf:
1045 case Attribute::SwiftAsync:
1046 case Attribute::ZExt:
1047 case Attribute::ImmArg:
1048 case Attribute::ByRef:
1049 case Attribute::WriteOnly:
1050 case Attribute::Writable:
1051 case Attribute::DeadOnUnwind:
1052 case Attribute::Range:
1053 case Attribute::Initializes:
1054 case Attribute::NoExt:
1060 case Attribute::DeadOnReturn:
1073 for (
Value *input : inputs) {
1074 if (StructValues.contains(input))
1077 ScalarAI->
setName(input->getName());
1078 if (input->isSwiftError())
1080 Attribute::SwiftError);
1083 for (
Value *output : outputs) {
1084 if (StructValues.contains(output))
1087 ScalarAI->
setName(output->getName() +
".out");
1093 auto Count = BFI->getProfileCountFromFreq(EntryFreq);
1094 if (
Count.has_value())
1112 if (!
I.getDebugLoc())
1139 Value *Mem =
II->getOperand(0);
1143 if (
II->getIntrinsicID() == Intrinsic::lifetime_start)
1144 LifetimesStart.
insert(Mem);
1145 II->eraseFromParent();
1160 bool InsertBefore) {
1161 for (
Value *Mem : Objects) {
1164 "Input memory not defined in original function");
1172 Marker->insertBefore(Term->getIterator());
1176 if (!LifetimesStart.
empty()) {
1177 insertMarkers(Intrinsic::lifetime_start, LifetimesStart,
1181 if (!LifetimesEnd.
empty()) {
1182 insertMarkers(Intrinsic::lifetime_end, LifetimesEnd,
1187void CodeExtractor::moveCodeToFunction(
Function *newFunction) {
1188 auto newFuncIt = newFunction->
begin();
1189 for (BasicBlock *
Block : Blocks) {
1191 Block->removeFromParent();
1198 newFuncIt = newFunction->
insert(std::next(newFuncIt),
Block);
1202void CodeExtractor::calculateNewCallTerminatorWeights(
1206 using Distribution = BlockFrequencyInfoImplBase::Distribution;
1207 using BlockNode = BlockFrequencyInfoImplBase::BlockNode;
1214 Distribution BranchDist;
1221 BlockNode ExitNode(i);
1224 BranchDist.addExit(ExitNode, ExitFreq);
1230 if (BranchDist.Total == 0) {
1231 BPI->setEdgeProbability(CodeReplacer, EdgeProbabilities);
1236 BranchDist.normalize();
1239 for (
unsigned I = 0,
E = BranchDist.Weights.size();
I <
E; ++
I) {
1240 const auto &Weight = BranchDist.Weights[
I];
1243 BranchWeights[Weight.TargetNode.Index] = Weight.Amount;
1244 BranchProbability BP(Weight.Amount, BranchDist.Total);
1245 EdgeProbabilities[Weight.TargetNode.Index] = BP;
1247 BPI->setEdgeProbability(CodeReplacer, EdgeProbabilities);
1249 LLVMContext::MD_prof,
1250 MDBuilder(TI->
getContext()).createBranchWeights(BranchWeights));
1260 if (DVR->getFunction() != &
F)
1261 DVR->eraseFromParent();
1292 assert(OldSP->getUnit() &&
"Missing compile unit for subprogram");
1297 DISubprogram::SPFlagOptimized |
1298 DISubprogram::SPFlagLocalToUnit;
1301 0, SPType, 0, DINode::FlagZero, SPFlags);
1304 auto UpdateOrInsertDebugRecord = [&](
auto *DR,
Value *OldLoc,
Value *NewLoc,
1306 if (DR->getParent()->getParent() == &NewFunc) {
1307 DR->replaceVariableLocationOp(OldLoc, NewLoc);
1311 DIB.
insertDeclare(NewLoc, DR->getVariable(), Expr, DR->getDebugLoc(),
1316 NewLoc, DR->getVariable(), Expr, DR->getDebugLoc(),
1327 for (
auto *DVR : DPUsers)
1328 UpdateOrInsertDebugRecord(DVR,
Input, NewVal, Expr, DVR->isDbgDeclare());
1331 auto IsInvalidLocation = [&NewFunc](
Value *Location) {
1339 return Arg->getParent() != &NewFunc;
1356 DINode *&NewVar = RemappedMetadata[OldVar];
1359 *OldVar->getScope(), *NewSP, Ctx, Cache);
1361 NewScope, OldVar->
getName(), OldVar->getFile(), OldVar->getLine(),
1362 OldVar->getType(),
false, DINode::FlagZero,
1363 OldVar->getAlignInBits());
1368 auto UpdateDbgLabel = [&](
auto *LabelRecord) {
1371 if (LabelRecord->getDebugLoc().getInlinedAt())
1373 DILabel *OldLabel = LabelRecord->getLabel();
1374 DINode *&NewLabel = RemappedMetadata[OldLabel];
1377 *OldLabel->
getScope(), *NewSP, Ctx, Cache);
1386 auto UpdateDbgRecordsOnInst = [&](
Instruction &
I) ->
void {
1387 for (
DbgRecord &DR :
I.getDbgRecordRange()) {
1389 UpdateDbgLabel(DLR);
1415 UpdateDbgRecordsOnInst(
I);
1417 for (
auto *DVR : DVRsToDelete)
1418 DVR->getMarker()->MarkedInstr->dropOneDbgRecord(DVR);
1430 *NewSP, Ctx, Cache));
1433 auto updateLoopInfoLoc = [&Ctx, &Cache, NewSP](
Metadata *MD) ->
Metadata * {
1449 ValueSet Inputs, Outputs;
1455 ValueSet &inputs, ValueSet &outputs) {
1464 normalizeCFGForExtraction(header);
1472 AC->unregisterAssumption(AI);
1473 AI->eraseFromParent();
1478 ValueSet SinkingCands, HoistingCands;
1480 findAllocas(CEAC, SinkingCands, HoistingCands, CommonExit);
1490 ValueSet LifetimesStart;
1493 if (!HoistingCands.
empty()) {
1496 for (
auto *
II : HoistingCands)
1498 computeExtractedFuncRetVals();
1508 assert(BPI &&
"Both BPI and BFI are required to preserve profile info");
1510 if (Blocks.count(Pred))
1513 BFI->getBlockFreq(Pred) * BPI->getEdgeProbability(Pred, header);
1516 for (
BasicBlock *Succ : ExtractedFuncRetVals) {
1518 if (!Blocks.count(
Block))
1523 BF += BFI->getBlockFreq(
Block) * BPI->getEdgeProbability(
Block, Succ);
1531 while (ReplIP && Blocks.count(ReplIP))
1535 std::string SuffixToUse =
1540 ValueSet StructValues;
1542 Function *newFunction = constructFunctionDeclaration(
1543 inputs, outputs, EntryFreq, oldFunction->
getName() +
"." + SuffixToUse,
1544 StructValues, StructTy);
1547 emitFunctionBody(inputs, outputs, StructValues, newFunction, StructTy, header,
1548 SinkingCands, NewValues);
1550 std::vector<Value *> Reloads;
1551 CallInst *TheCall = emitReplacerCall(
1552 inputs, outputs, StructValues, newFunction, StructTy, oldFunction, ReplIP,
1553 EntryFreq, LifetimesStart.
getArrayRef(), Reloads);
1555 insertReplacerCall(oldFunction, header, TheCall, outputs, Reloads,
1570void CodeExtractor::normalizeCFGForExtraction(
BasicBlock *&header) {
1573 splitReturnBlocks();
1576 severSplitPHINodesOfEntry(header);
1582 computeExtractedFuncRetVals();
1583 severSplitPHINodesOfExits();
1586void CodeExtractor::computeExtractedFuncRetVals() {
1587 ExtractedFuncRetVals.clear();
1592 if (Blocks.count(Succ))
1595 bool IsNew = ExitBlocks.
insert(Succ).second;
1597 ExtractedFuncRetVals.push_back(Succ);
1602Type *CodeExtractor::getSwitchType() {
1605 assert(ExtractedFuncRetVals.size() < 0xffff &&
1606 "too many exit blocks for switch");
1607 switch (ExtractedFuncRetVals.size()) {
1619void CodeExtractor::emitFunctionBody(
1620 const ValueSet &inputs,
const ValueSet &outputs,
1621 const ValueSet &StructValues,
Function *newFunction,
1635 for (
auto *
II : SinkingCands) {
1641 for (
auto *
II : SinkingCands) {
1648 Argument *AggArg = StructValues.empty()
1654 for (
unsigned i = 0, e = inputs.size(), aggIdx = 0; i != e; ++i) {
1656 if (StructValues.contains(inputs[i])) {
1661 StructArgTy, AggArg, Idx,
"gep_" + inputs[i]->
getName(), newFuncRoot);
1664 "loadgep_" + inputs[i]->getName(), newFuncRoot);
1677 unsigned AlignmentValue;
1678 const Triple &TargetTriple =
1686 inputs[i]->stripPointerCasts()->getPointerAlignment(
DL).value();
1688 AlignmentValue = inputs[i]->getPointerAlignment(
DL).value();
1691 LLVMContext::MD_align,
1694 MDB.createConstant(ConstantInt::get(
1697 RewriteVal = LoadGEP;
1700 RewriteVal = &*ScalarAI++;
1705 moveCodeToFunction(newFunction);
1707 for (
unsigned i = 0, e = inputs.size(); i != e; ++i) {
1708 Value *RewriteVal = NewValues[i];
1710 std::vector<User *>
Users(inputs[i]->user_begin(), inputs[i]->user_end());
1713 if (Blocks.count(inst->getParent()))
1714 inst->replaceUsesOfWith(inputs[i], RewriteVal);
1722 std::map<BasicBlock *, BasicBlock *> ExitBlockMap;
1726 for (
auto P :
enumerate(ExtractedFuncRetVals)) {
1728 size_t SuccNum =
P.index();
1732 ExitBlockMap[OldTarget] = NewTarget;
1734 Value *brVal =
nullptr;
1735 Type *RetTy = FuncRetVal ? FuncRetVal->getType() : getSwitchType();
1736 assert(ExtractedFuncRetVals.size() < 0xffff &&
1737 "too many exit blocks for switch");
1738 switch (ExtractedFuncRetVals.size()) {
1747 brVal = ConstantInt::get(RetTy, !SuccNum);
1750 brVal = ConstantInt::get(RetTy, SuccNum);
1757 for (BasicBlock *
Block : Blocks) {
1764 BasicBlock *NewTarget = ExitBlockMap[OldTarget];
1765 assert(NewTarget &&
"Unknown target block!");
1789 unsigned AggIdx = 0;
1791 for (
Value *Input : inputs) {
1792 if (StructValues.contains(Input))
1798 for (
Value *Output : outputs) {
1805 InsertPt = InvokeI->getNormalDest()->getFirstInsertionPt();
1807 InsertPt =
Phi->getParent()->getFirstInsertionPt();
1809 InsertPt = std::next(OutI->getIterator());
1812 if (StructValues.contains(Output))
1819 assert((InsertPt->getFunction() == newFunction ||
1820 Blocks.count(InsertPt->getParent())) &&
1821 "InsertPt should be in new function");
1823 if (StructValues.contains(Output)) {
1824 assert(AggArg &&
"Number of aggregate output arguments should match "
1825 "the number of defined values");
1830 StructArgTy, AggArg, Idx,
"gep_" + Output->getName(), InsertPt);
1831 new StoreInst(Output,
GEP, InsertPt);
1835 "Number of scalar output arguments should match "
1836 "the number of defined values");
1837 new StoreInst(Output, &*ScalarAI, InsertPt);
1842 if (ExtractedFuncRetVals.empty()) {
1846 if (
none_of(Blocks, [](
const BasicBlock *BB) {
1854CallInst *CodeExtractor::emitReplacerCall(
1855 const ValueSet &inputs,
const ValueSet &outputs,
1856 const ValueSet &StructValues,
Function *newFunction,
1859 std::vector<Value *> &Reloads) {
1866 if (AllocationBlock)
1867 assert(AllocationBlock->getParent() == oldFunction &&
1868 "AllocationBlock is not in the same function");
1870 AllocationBlock ? AllocationBlock : &oldFunction->
getEntryBlock();
1874 BFI->setBlockFreq(codeReplacer, EntryFreq);
1876 std::vector<Value *> params;
1879 for (
Value *input : inputs) {
1880 if (StructValues.contains(input))
1883 params.push_back(input);
1887 std::vector<Value *> ReloadOutputs;
1888 for (
Value *output : outputs) {
1889 if (StructValues.contains(output))
1895 output->getType(), output->getName() +
".loc");
1896 params.push_back(OutAlloc);
1897 ReloadOutputs.push_back(OutAlloc);
1901 if (!StructValues.empty()) {
1902 AddrSpaceCastInst *StructSpaceCast =
nullptr;
1905 StructArgTy,
"structArg", &StructSpaceCast);
1906 if (StructSpaceCast)
1907 params.push_back(StructSpaceCast);
1909 params.push_back(Struct);
1911 unsigned AggIdx = 0;
1912 for (
Value *input : inputs) {
1913 if (!StructValues.contains(input))
1920 StructArgTy, Struct, Idx,
"gep_" + input->getName());
1921 GEP->insertInto(codeReplacer, codeReplacer->
end());
1922 new StoreInst(input,
GEP, codeReplacer);
1930 newFunction, params, ExtractedFuncRetVals.size() > 1 ?
"targetBlock" :
"",
1934 unsigned ParamIdx = 0;
1935 unsigned AggIdx = 0;
1936 for (
auto input : inputs) {
1937 if (StructValues.contains(input)) {
1940 if (input->isSwiftError())
1957 for (
unsigned i = 0, e = outputs.size(), scalarIdx = 0; i != e; ++i) {
1958 Value *Output =
nullptr;
1959 if (StructValues.contains(outputs[i])) {
1964 StructArgTy, Struct, Idx,
"gep_reload_" + outputs[i]->
getName());
1965 GEP->insertInto(codeReplacer, codeReplacer->
end());
1969 Output = ReloadOutputs[scalarIdx];
1973 new LoadInst(outputs[i]->
getType(), Output,
1974 outputs[i]->
getName() +
".reload", codeReplacer);
1975 Reloads.push_back(
load);
1979 SwitchInst *TheSwitch =
1981 codeReplacer, 0, codeReplacer);
1982 for (
auto P :
enumerate(ExtractedFuncRetVals)) {
1984 size_t SuccNum =
P.index();
1991 Type *OldFnRetTy = TheSwitch->
getParent()->getParent()->getReturnType();
1992 switch (ExtractedFuncRetVals.size()) {
2000 }
else if (OldFnRetTy->
isVoidTy()) {
2053 auto deallocVars = [&](
BasicBlock *DeallocBlock,
2056 for (
Value *Output : outputs) {
2057 if (!StructValues.contains(Output))
2058 deallocateVar(IRBuilder<>::InsertPoint(DeallocBlock, DeallocIP),
2059 ReloadOutputs[Index++], Output->
getType());
2063 deallocateVar(IRBuilder<>::InsertPoint(DeallocBlock, DeallocIP), Struct,
2067 if (DeallocationBlocks.empty()) {
2068 deallocVars(codeReplacer, codeReplacer->
end());
2070 for (BasicBlock *DeallocationBlock : DeallocationBlocks)
2071 deallocVars(DeallocationBlock, DeallocationBlock->getFirstInsertionPt());
2077void CodeExtractor::insertReplacerCall(
2087 for (
auto &U :
Users)
2091 if (
I->isTerminator() &&
I->getFunction() == oldFunction &&
2092 !Blocks.count(
I->getParent()))
2093 I->replaceUsesOfWith(header, codeReplacer);
2099 for (BasicBlock *ExitBB : ExtractedFuncRetVals)
2100 for (PHINode &PN : ExitBB->phis()) {
2101 Value *IncomingCodeReplacerVal =
nullptr;
2108 if (!IncomingCodeReplacerVal) {
2113 "PHI has two incompatbile incoming values from codeRepl");
2117 for (
unsigned i = 0, e = outputs.size(); i != e; ++i) {
2119 std::vector<User *>
Users(outputs[i]->user_begin(), outputs[i]->user_end());
2120 for (User *U :
Users) {
2122 if (inst->
getParent()->getParent() == oldFunction)
2128 for (User *U : FuncRetVal->users()) {
2130 if (inst->
getParent()->getParent() == oldFunction)
2135 if (BFI && ExtractedFuncRetVals.size() > 1)
2136 calculateNewCallTerminatorWeights(codeReplacer, ExitWeights, BPI);
2142 for (
auto AssumeVH : AC->assumptions()) {
2148 if (
I->getFunction() != &OldFunc)
2154 for (
auto AffectedValVH : AC->assumptionsFor(
I->getOperand(0))) {
2158 if (AffectedCI->getFunction() != &OldFunc)
2161 if (AssumedInst->getFunction() != &OldFunc)
2169 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)
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 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.
LLVM_ABI const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
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.
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.
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).
InsertPoint - A saved insertion point.
BasicBlock * getBlock() const
BasicBlock::iterator getPoint() const
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)
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.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
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 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.
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 * > 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.
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.