87#define DEBUG_TYPE "inline-function"
95 cl::desc(
"Convert noalias attributes to metadata during inlining."));
100 cl::desc(
"Use the llvm.experimental.noalias.scope.decl "
101 "intrinsic during inlining."));
109 cl::desc(
"Convert align attributes to assumptions during inlining."));
112 "max-inst-checked-for-throw-during-inlining",
cl::Hidden,
113 cl::desc(
"the maximum number of instructions analyzed for may throw during "
114 "attribute inference in inlined body"),
120 class LandingPadInliningInfo {
131 PHINode *InnerEHValuesPHI =
nullptr;
137 : OuterResumeDest(
II->getUnwindDest()) {
146 UnwindDestPHIValues.
push_back(
PHI->getIncomingValueForBlock(InvokeBB));
155 return OuterResumeDest;
160 LandingPadInst *getLandingPadInst()
const {
return CallerLPad; }
167 void forwardResume(ResumeInst *RI);
171 void addIncomingPHIValuesFor(BasicBlock *BB)
const {
172 addIncomingPHIValuesForInto(BB, OuterResumeDest);
175 void addIncomingPHIValuesForInto(BasicBlock *src, BasicBlock *dest)
const {
177 for (
unsigned i = 0, e = UnwindDestPHIValues.size(); i != e; ++i, ++
I) {
179 phi->addIncoming(UnwindDestPHIValues[i], src);
187 while (It != BB.
end()) {
189 if (IntrinsicCall->isEntry()) {
190 return IntrinsicCall;
199BasicBlock *LandingPadInliningInfo::getInnerResumeDest() {
200 if (InnerResumeDest)
return InnerResumeDest;
206 OuterResumeDest->
getName() +
".body");
209 const unsigned PHICapacity = 2;
214 for (
unsigned i = 0, e = UnwindDestPHIValues.
size(); i != e; ++i, ++
I) {
217 OuterPHI->
getName() +
".lpad-body");
228 InnerEHValuesPHI->
addIncoming(CallerLPad, OuterResumeDest);
231 return InnerResumeDest;
238void LandingPadInliningInfo::forwardResume(ResumeInst *RI) {
247 addIncomingPHIValuesForInto(Src, Dest);
256 return FPI->getParentPad();
268 while (!Worklist.
empty()) {
275 Value *UnwindDestToken =
nullptr;
277 if (CatchSwitch->hasUnwindDest()) {
278 UnwindDestToken = &*CatchSwitch->getUnwindDest()->getFirstNonPHIIt();
286 for (
auto HI = CatchSwitch->handler_begin(),
287 HE = CatchSwitch->handler_end();
288 HI != HE && !UnwindDestToken; ++HI) {
301 auto Memo = MemoMap.
find(ChildPad);
302 if (Memo == MemoMap.
end()) {
309 Value *ChildUnwindDestToken = Memo->second;
310 if (!ChildUnwindDestToken)
317 UnwindDestToken = ChildUnwindDestToken;
328 if (
BasicBlock *RetUnwindDest = CleanupRet->getUnwindDest())
329 UnwindDestToken = &*RetUnwindDest->getFirstNonPHIIt();
334 Value *ChildUnwindDestToken;
336 ChildUnwindDestToken = &*Invoke->getUnwindDest()->getFirstNonPHIIt();
339 auto Memo = MemoMap.
find(ChildPad);
340 if (Memo == MemoMap.
end()) {
347 ChildUnwindDestToken = Memo->second;
348 if (!ChildUnwindDestToken)
360 UnwindDestToken = ChildUnwindDestToken;
366 if (!UnwindDestToken)
377 UnwindParent =
nullptr;
378 bool ExitedOriginalPad =
false;
380 ExitedPad && ExitedPad != UnwindParent;
385 MemoMap[ExitedPad] = UnwindDestToken;
386 ExitedOriginalPad |= (ExitedPad == EHPad);
389 if (ExitedOriginalPad)
390 return UnwindDestToken;
422 EHPad = CPI->getCatchSwitch();
425 auto Memo = MemoMap.
find(EHPad);
426 if (Memo != MemoMap.
end())
431 assert((UnwindDestToken ==
nullptr) != (MemoMap.
count(EHPad) != 0));
433 return UnwindDestToken;
440 MemoMap[EHPad] =
nullptr;
446 Value *AncestorToken;
460 assert(!MemoMap.
count(AncestorPad) || MemoMap[AncestorPad]);
461 auto AncestorMemo = MemoMap.
find(AncestorPad);
462 if (AncestorMemo == MemoMap.
end()) {
465 UnwindDestToken = AncestorMemo->second;
469 LastUselessPad = AncestorPad;
470 MemoMap[LastUselessPad] =
nullptr;
472 TempMemos.
insert(LastUselessPad);
490 while (!Worklist.
empty()) {
492 auto Memo = MemoMap.
find(UselessPad);
493 if (Memo != MemoMap.
end() && Memo->second) {
521 MemoMap[UselessPad] = UnwindDestToken;
523 assert(CatchSwitch->getUnwindDest() ==
nullptr &&
"Expected useless pad");
524 for (
BasicBlock *HandlerBlock : CatchSwitch->handlers()) {
525 auto *CatchPad = &*HandlerBlock->getFirstNonPHIIt();
530 ->getFirstNonPHIIt()) == CatchPad)) &&
531 "Expected useless pad");
545 "Expected useless pad");
552 return UnwindDestToken;
578 if (
F->getIntrinsicID() == Intrinsic::experimental_deoptimize ||
579 F->getIntrinsicID() == Intrinsic::experimental_guard)
591 Value *UnwindDestToken =
598 MemoKey = CatchPad->getCatchSwitch();
600 MemoKey = FuncletPad;
601 assert(FuncletUnwindMap->count(MemoKey) &&
602 (*FuncletUnwindMap)[MemoKey] == UnwindDestToken &&
603 "must get memoized to avoid confusing later searches");
631 LandingPadInliningInfo Invoke(
II);
639 InlinedLPads.
insert(
II->getLandingPadInst());
646 InlinedLPad->reserveClauses(OuterNum);
647 for (
unsigned OuterIdx = 0; OuterIdx != OuterNum; ++OuterIdx)
648 InlinedLPad->addClause(OuterLPad->
getClause(OuterIdx));
650 InlinedLPad->setCleanup(
true);
657 &*BB, Invoke.getOuterResumeDest(), InlinedCodeInfo))
660 Invoke.addIncomingPHIValuesFor(NewBB);
664 Invoke.forwardResume(RI);
694 UnwindDestPHIValues.
push_back(
PHI.getIncomingValueForBlock(InvokeBB));
701 for (
Value *
V : UnwindDestPHIValues) {
703 PHI->addIncoming(
V, Src);
714 if (CRI->unwindsToCaller()) {
715 auto *CleanupPad = CRI->getCleanupPad();
717 CRI->eraseFromParent();
725 FuncletUnwindMap[CleanupPad] =
736 if (CatchSwitch->unwindsToCaller()) {
737 Value *UnwindDestToken;
738 if (
auto *ParentPad =
762 CatchSwitch->getParentPad(), UnwindDest,
763 CatchSwitch->getNumHandlers(), CatchSwitch->
getName(),
764 CatchSwitch->getIterator());
765 for (
BasicBlock *PadBB : CatchSwitch->handlers())
766 NewCatchSwitch->addHandler(PadBB);
771 FuncletUnwindMap[NewCatchSwitch] = UnwindDestToken;
772 Replacement = NewCatchSwitch;
780 I->replaceAllUsesWith(Replacement);
781 I->eraseFromParent();
791 &*BB, UnwindDest, InlinedCodeInfo, &FuncletUnwindMap))
804 MDNode *CallsiteStackContext) {
810 for (
auto MIBStackIter = MIBStackContext->
op_begin(),
811 CallsiteStackIter = CallsiteStackContext->
op_begin();
812 MIBStackIter != MIBStackContext->
op_end() &&
813 CallsiteStackIter != CallsiteStackContext->
op_end();
814 MIBStackIter++, CallsiteStackIter++) {
818 if (Val1->getZExtValue() != Val2->getZExtValue())
825 Call->setMetadata(LLVMContext::MD_memprof,
nullptr);
829 Call->setMetadata(LLVMContext::MD_callsite,
nullptr);
833 const std::vector<Metadata *> &MIBList,
842 bool MemprofMDAttached =
CallStack.buildAndAttachMIBMetadata(CI);
844 if (!MemprofMDAttached)
854 MDNode *InlinedCallsiteMD,
857 MDNode *ClonedCallsiteMD =
nullptr;
860 if (OrigCallsiteMD) {
865 ClonedCall->
setMetadata(LLVMContext::MD_callsite, ClonedCallsiteMD);
877 std::vector<Metadata *> NewMIBList;
882 for (
auto &MIBOp : OrigMemProfMD->
operands()) {
890 NewMIBList.push_back(MIB);
892 if (NewMIBList.empty()) {
908 bool ContainsMemProfMetadata,
914 if (!CallsiteMD && !ContainsMemProfMetadata)
918 for (
const auto &Entry : VMap) {
923 if (!OrigCall || !ClonedCall)
945 while (!Worklist.
empty()) {
965 if (Stored && Stored->
getType() == LI->getType())
986 if (
Value *RV = RI->getReturnValue())
989 for (
CallBase *OrigCall : AllocCalls) {
994 if (InlinedFunctionInfo.
isSimplified(OrigCall, ClonedCall))
999 if (
MDNode *MD = ClonedCall->getMetadata(LLVMContext::MD_alloc_token)) {
1000 if (MD->getNumOperands() != 3 ||
1004 ClonedCall->setMetadata(LLVMContext::MD_alloc_token, AllocTokenMD);
1013 MDNode *MemParallelLoopAccess =
1014 CB.
getMetadata(LLVMContext::MD_mem_parallel_loop_access);
1018 if (!MemParallelLoopAccess && !AccessGroup && !AliasScope && !NoAlias)
1024 if (!
I.mayReadOrWriteMemory())
1027 if (MemParallelLoopAccess) {
1030 I.getMetadata(LLVMContext::MD_mem_parallel_loop_access),
1031 MemParallelLoopAccess);
1032 I.setMetadata(LLVMContext::MD_mem_parallel_loop_access,
1033 MemParallelLoopAccess);
1038 I.getMetadata(LLVMContext::MD_access_group), AccessGroup));
1042 I.getMetadata(LLVMContext::MD_alias_scope), AliasScope));
1046 I.getMetadata(LLVMContext::MD_noalias), NoAlias));
1060 InlineSiteLoc = CI->getZExtValue();
1070 if (!CI || !CI->getMetadata(
"srcloc"))
1072 auto *Callee = CI->getCalledFunction();
1073 if (!Callee || (!Callee->hasFnAttribute(
"dontcall-error") &&
1074 !Callee->hasFnAttribute(
"dontcall-warn")))
1078 if (
MDNode *Existing = CI->getMetadata(
"inlined.from"))
1082 Ops.push_back(MakeMDInt(0));
1085 Ops.push_back(MakeMDInt(InlineSiteLoc));
1106 if (CalledFn && CalledFn->isIntrinsic() &&
I->doesNotThrow() &&
1111 I->getOperandBundlesAsDefs(OpBundles);
1116 I->replaceAllUsesWith(NewInst);
1118 I->eraseFromParent();
1127class ScopedAliasMetadataDeepCloner {
1128 using MetadataMap = DenseMap<const MDNode *, TrackingMDNodeRef>;
1129 SetVector<const MDNode *> MD;
1131 void addRecursiveMetadataUses();
1134 ScopedAliasMetadataDeepCloner(
const Function *
F);
1146ScopedAliasMetadataDeepCloner::ScopedAliasMetadataDeepCloner(
1148 for (
const BasicBlock &BB : *
F) {
1149 for (
const Instruction &
I : BB) {
1150 if (
const MDNode *M =
I.getMetadata(LLVMContext::MD_alias_scope))
1152 if (
const MDNode *M =
I.getMetadata(LLVMContext::MD_noalias))
1157 MD.insert(Decl->getScopeList());
1160 addRecursiveMetadataUses();
1163void ScopedAliasMetadataDeepCloner::addRecursiveMetadataUses() {
1165 while (!
Queue.empty()) {
1169 if (MD.insert(OpMD))
1170 Queue.push_back(OpMD);
1174void ScopedAliasMetadataDeepCloner::clone() {
1175 assert(MDMap.
empty() &&
"clone() already called ?");
1178 for (
const MDNode *
I : MD) {
1180 MDMap[
I].reset(DummyNodes.
back().get());
1187 for (
const MDNode *
I : MD) {
1209 for (BasicBlock &BB :
make_range(FStart, FEnd)) {
1210 for (Instruction &
I : BB) {
1213 if (MDNode *M =
I.getMetadata(LLVMContext::MD_alias_scope))
1214 if (MDNode *MNew = MDMap.
lookup(M))
1215 I.setMetadata(LLVMContext::MD_alias_scope, MNew);
1217 if (MDNode *M =
I.getMetadata(LLVMContext::MD_noalias))
1218 if (MDNode *MNew = MDMap.
lookup(M))
1219 I.setMetadata(LLVMContext::MD_noalias, MNew);
1222 if (MDNode *MNew = MDMap.
lookup(Decl->getScopeList()))
1223 Decl->setScopeList(MNew);
1242 if (CB.
paramHasAttr(Arg.getArgNo(), Attribute::NoAlias) && !Arg.use_empty())
1245 if (NoAliasArgs.
empty())
1267 for (
unsigned i = 0, e = NoAliasArgs.
size(); i != e; ++i) {
1270 std::string Name = std::string(CalledFunc->
getName());
1273 Name +=
A->getName();
1275 Name +=
": argument ";
1283 NewScopes.
insert(std::make_pair(
A, NewScope));
1290 IRBuilder<>(&CB).CreateNoAliasScopeDeclaration(AScopeList);
1300 VMI != VMIE; ++VMI) {
1309 bool IsArgMemOnlyCall =
false, IsFuncCall =
false;
1313 PtrArgs.
push_back(LI->getPointerOperand());
1317 PtrArgs.
push_back(VAAI->getPointerOperand());
1319 PtrArgs.
push_back(CXI->getPointerOperand());
1321 PtrArgs.
push_back(RMWI->getPointerOperand());
1326 if (
Call->doesNotAccessMemory())
1338 IsArgMemOnlyCall =
true;
1345 if (!Arg->getType()->isPointerTy())
1356 if (PtrArgs.
empty() && !IsFuncCall)
1365 for (
const Value *
V : PtrArgs) {
1374 bool RequiresNoCaptureBefore =
false, UsesAliasingPtr =
false,
1375 UsesUnknownObject =
false;
1376 for (
const Value *
V : ObjSet) {
1391 UsesAliasingPtr =
true;
1393 UsesAliasingPtr =
true;
1399 RequiresNoCaptureBefore =
true;
1405 UsesUnknownObject =
true;
1411 if (UsesUnknownObject)
1416 if (IsFuncCall && !IsArgMemOnlyCall)
1417 RequiresNoCaptureBefore =
true;
1429 bool CanAddScopes = !UsesAliasingPtr && (!IsFuncCall || IsArgMemOnlyCall);
1433 Scopes.push_back(NewScopes[
A]);
1437 if (!Scopes.empty()) {
1439 LLVMContext::MD_alias_scope,
1462 if (!RequiresNoCaptureBefore ||
1464 A,
false,
I, &DT,
false,
1482 "Expected to be in same basic block!");
1484 assert(BeginIt !=
End->getIterator() &&
"Non-empty BB has empty iterator");
1495 auto &Context = CalledFunction->
getContext();
1499 bool HasAttrToPropagate =
false;
1507 Attribute::Dereferenceable, Attribute::DereferenceableOrNull,
1508 Attribute::NonNull, Attribute::NoFPClass,
1509 Attribute::Alignment, Attribute::Range};
1517 ValidObjParamAttrs.
back().addAttribute(Attribute::ReadNone);
1519 ValidObjParamAttrs.
back().addAttribute(Attribute::ReadOnly);
1524 ValidExactParamAttrs.
back().addAttribute(Attr);
1527 HasAttrToPropagate |= ValidObjParamAttrs.
back().hasAttributes();
1528 HasAttrToPropagate |= ValidExactParamAttrs.
back().hasAttributes();
1532 if (!HasAttrToPropagate)
1545 if (InlinedFunctionInfo.
isSimplified(InnerCB, NewInnerCB))
1549 for (
unsigned I = 0,
E = InnerCB->arg_size();
I <
E; ++
I) {
1554 if (NewInnerCB->isByValArgument(
I))
1558 if (
match(NewInnerCB->getArgOperand(
I),
1574 if (AL.getParamDereferenceableBytes(
I) >
1575 NewAB.getDereferenceableBytes())
1576 NewAB.removeAttribute(Attribute::Dereferenceable);
1577 if (AL.getParamDereferenceableOrNullBytes(
I) >
1578 NewAB.getDereferenceableOrNullBytes())
1579 NewAB.removeAttribute(Attribute::DereferenceableOrNull);
1580 if (AL.getParamAlignment(
I).valueOrOne() >
1581 NewAB.getAlignment().valueOrOne())
1582 NewAB.removeAttribute(Attribute::Alignment);
1583 if (
auto ExistingRange = AL.getParamRange(
I)) {
1584 if (
auto NewRange = NewAB.getRange()) {
1587 NewAB.removeAttribute(Attribute::Range);
1588 NewAB.addRangeAttr(CombinedRange);
1592 if (
FPClassTest ExistingNoFP = AL.getParamNoFPClass(
I))
1593 NewAB.addNoFPClassAttr(ExistingNoFP | NewAB.getNoFPClass());
1595 AL = AL.addParamAttributes(Context,
I, NewAB);
1596 }
else if (NewInnerCB->getArgOperand(
I)->getType()->isPointerTy()) {
1598 const Value *UnderlyingV =
1609 AL = AL.addParamAttributes(Context,
I, ValidObjParamAttrs[ArgNo]);
1616 if (AL.hasParamAttr(
I, Attribute::ReadOnly) &&
1617 AL.hasParamAttr(
I, Attribute::WriteOnly))
1618 AL = AL.addParamAttribute(Context,
I, Attribute::ReadNone);
1621 if (AL.hasParamAttr(
I, Attribute::ReadNone)) {
1622 AL = AL.removeParamAttribute(Context,
I, Attribute::ReadOnly);
1623 AL = AL.removeParamAttribute(Context,
I, Attribute::WriteOnly);
1627 if (AL.hasParamAttr(
I, Attribute::ReadOnly) ||
1628 AL.hasParamAttr(
I, Attribute::ReadNone))
1629 AL = AL.removeParamAttribute(Context,
I, Attribute::Writable);
1631 NewInnerCB->setAttributes(AL);
1645 Valid.addDereferenceableAttr(DerefBytes);
1647 Valid.addDereferenceableOrNullAttr(DerefOrNullBytes);
1649 Valid.addAttribute(Attribute::NoAlias);
1651 Valid.addAttribute(Attribute::NoUndef);
1660 Valid.addAttribute(Attribute::NonNull);
1664 Valid.addRangeAttr(*
Range);
1674 if (!CallSiteValidUB.hasAttributes() && !CallSiteValidPG.hasAttributes())
1677 auto &Context = CalledFunction->
getContext();
1679 for (
auto &BB : *CalledFunction) {
1693 if (InlinedFunctionInfo.
isSimplified(RetVal, NewRetVal))
1713 if (RI->
getParent() != RetVal->getParent() ||
1725 if (ValidUB.getDereferenceableBytes() < AL.getRetDereferenceableBytes())
1726 ValidUB.removeAttribute(Attribute::Dereferenceable);
1727 if (ValidUB.getDereferenceableOrNullBytes() <
1728 AL.getRetDereferenceableOrNullBytes())
1729 ValidUB.removeAttribute(Attribute::DereferenceableOrNull);
1730 AttributeList NewAL = AL.addRetAttributes(Context, ValidUB);
1763 if (ValidPG.getAlignment().valueOrOne() < AL.getRetAlignment().valueOrOne())
1764 ValidPG.removeAttribute(Attribute::Alignment);
1765 if (ValidPG.hasAttributes()) {
1766 Attribute CBRange = ValidPG.getAttribute(Attribute::Range);
1768 Attribute NewRange = AL.getRetAttr(Attribute::Range);
1770 ValidPG.addRangeAttr(
1775 Attribute CBNoFPClass = ValidPG.getAttribute(Attribute::NoFPClass);
1776 if (CBNoFPClass.
isValid() && AL.hasRetAttr(Attribute::NoFPClass)) {
1777 ValidPG.addNoFPClassAttr(
1779 AL.getRetAttr(Attribute::NoFPClass).getNoFPClass());
1794 (RetVal->hasOneUse() && !RetVal->hasRetAttr(Attribute::NoUndef)))
1795 NewAL = NewAL.addRetAttributes(Context, ValidPG);
1797 NewRetVal->setAttributes(NewAL);
1813 bool DTCalculated =
false;
1817 if (!Arg.getType()->isPointerTy() || Arg.hasPassPointeeByValueCopyAttr() ||
1824 if (!DTCalculated) {
1826 DTCalculated =
true;
1835 DL, ArgVal, Alignment->value());
1848 Builder.getInt64(M->getDataLayout().getTypeAllocSize(ByValType));
1850 Align DstAlign = Dst->getPointerAlignment(M->getDataLayout());
1853 CallInst *CI = Builder.CreateMemCpy(Dst, DstAlign, Src, SrcAlign,
Size);
1897 Align Alignment =
DL.getPrefTypeAlign(ByValType);
1903 Alignment = std::max(Alignment, *ByValAlignment);
1907 nullptr, Alignment, Arg->
getName());
1933 OrigDL->getInlinedAt()
1940 InlineLocs[OrigDL.
get()] = Result;
1961 DebugLoc TheCallDLForInlinedCall = TheCallDL;
1962 uint32_t Discriminator = TheCallDLForInlinedCall->getDiscriminator();
1964 std::optional<uint32_t> DwarfDiscriminator =
1968 DwarfDiscriminator.value_or(0));
1979 Ctx, InlinedAtNode->getLine(), InlinedAtNode->getColumn(),
1980 InlinedAtNode->getScope(), InlinedAtNode->getInlinedAt(),
1992 bool NoInlineLineTables = Fn->
hasFnAttribute(
"no-inline-line-tables");
1998 auto updateLoopInfoLoc = [&Ctx, &InlinedAtNode, &IANodes,
2007 if (!NoInlineLineTables)
2010 IANodes, InlineLocs);
2015 if (CalleeHasDebugInfo && !NoInlineLineTables)
2035 I.setDebugLoc(
isa<CallBase>(
I) ? TheCallDLForInlinedCall : TheCallDL);
2040 assert(DVR->getDebugLoc() &&
"Debug Value must have debug loc");
2041 if (NoInlineLineTables) {
2042 DVR->setDebugLoc(TheCallDL);
2048 IANodes, InlineLocs);
2049 DVR->setDebugLoc(IDL);
2053 for (; FI != Fn->
end(); ++FI) {
2056 for (
DbgRecord &DVR :
I.getDbgRecordRange()) {
2062 if (NoInlineLineTables) {
2064 while (BI != FI->end()) {
2065 BI->dropDbgRecords();
2073#define DEBUG_TYPE "assignment-tracking"
2081 errs() <<
"# Finding caller local variables escaped by callee\n");
2084 if (!Arg->getType()->isPointerTy()) {
2096 assert(Arg->getType()->isPtrOrPtrVectorTy());
2097 APInt TmpOffset(
DL.getIndexTypeSizeInBits(Arg->getType()), 0,
false);
2099 Arg->stripAndAccumulateConstantOffsets(
DL, TmpOffset,
true));
2101 LLVM_DEBUG(
errs() <<
" | SKIP: Couldn't walk back to base storage\n");
2114 if (DbgAssign->getDebugLoc().getInlinedAt())
2121 return EscapedLocals;
2127 <<
Start->getParent()->getName() <<
" from "
2140 for (
auto BBI =
Start; BBI !=
End; ++BBI) {
2146#define DEBUG_TYPE "inline-function"
2160 for (
auto Entry : VMap) {
2166 if (!ClonedBBs.
insert(ClonedBB).second) {
2178 EntryClone, CallerBFI->
getBlockFreq(CallSiteBlock), ClonedBBs);
2186 if (CalleeEntryCount < 1)
2188 auto CallSiteCount =
2190 int64_t CallCount = std::min(CallSiteCount.value_or(0), CalleeEntryCount);
2195 Function *Callee, int64_t EntryDelta,
2197 auto CalleeCount = Callee->getEntryCount();
2203 const uint64_t NewEntryCount =
2204 (EntryDelta < 0 && static_cast<uint64_t>(-EntryDelta) > *CalleeCount)
2206 : *CalleeCount + EntryDelta;
2208 auto updateVTableProfWeight = [](
CallBase *CB,
const uint64_t NewEntryCount,
2209 const uint64_t PriorEntryCount) {
2217 uint64_t CloneEntryCount = *CalleeCount - NewEntryCount;
2218 for (
auto Entry : *VMap) {
2221 CI->updateProfWeight(CloneEntryCount, *CalleeCount);
2222 updateVTableProfWeight(CI, CloneEntryCount, *CalleeCount);
2227 II->updateProfWeight(CloneEntryCount, *CalleeCount);
2228 updateVTableProfWeight(
II, CloneEntryCount, *CalleeCount);
2234 Callee->setEntryCount(NewEntryCount);
2238 if (!VMap || VMap->
count(&BB))
2241 CI->updateProfWeight(NewEntryCount, *CalleeCount);
2242 updateVTableProfWeight(CI, NewEntryCount, *CalleeCount);
2245 II->updateProfWeight(NewEntryCount, *CalleeCount);
2246 updateVTableProfWeight(
II, NewEntryCount, *CalleeCount);
2277 for (
auto *RI : Returns) {
2279 bool InsertRetainCall = !IsUnsafeClaimRV;
2292 if (
II->getIntrinsicID() != Intrinsic::objc_autoreleaseReturnValue ||
2302 if (IsUnsafeClaimRV) {
2303 Builder.SetInsertPoint(
II);
2304 Builder.CreateIntrinsic(Intrinsic::objc_release, RetOpnd);
2306 II->eraseFromParent();
2307 InsertRetainCall =
false;
2326 NewCall->copyMetadata(*CI);
2327 CI->replaceAllUsesWith(NewCall);
2329 CI->eraseFromParent();
2330 InsertRetainCall =
false;
2334 if (InsertRetainCall) {
2338 Builder.SetInsertPoint(RI);
2339 Builder.CreateIntrinsic(Intrinsic::objc_retain, RetOpnd);
2365static std::pair<std::vector<int64_t>, std::vector<int64_t>>
2373 std::vector<int64_t> CalleeCounterMap;
2374 std::vector<int64_t> CalleeCallsiteMap;
2375 CalleeCounterMap.resize(CalleeCounters, -1);
2376 CalleeCallsiteMap.resize(CalleeCallsites, -1);
2379 if (Ins.getNameValue() == &Caller)
2381 const auto OldID =
static_cast<uint32_t>(Ins.getIndex()->getZExtValue());
2382 if (CalleeCounterMap[OldID] == -1)
2384 const auto NewID =
static_cast<uint32_t>(CalleeCounterMap[OldID]);
2386 Ins.setNameValue(&Caller);
2387 Ins.setIndex(NewID);
2392 if (Ins.getNameValue() == &Caller)
2394 const auto OldID =
static_cast<uint32_t>(Ins.getIndex()->getZExtValue());
2395 if (CalleeCallsiteMap[OldID] == -1)
2397 const auto NewID =
static_cast<uint32_t>(CalleeCallsiteMap[OldID]);
2399 Ins.setNameValue(&Caller);
2400 Ins.setIndex(NewID);
2404 std::deque<BasicBlock *> Worklist;
2421 Worklist.push_back(StartBB);
2422 while (!Worklist.empty()) {
2423 auto *BB = Worklist.front();
2424 Worklist.pop_front();
2428 Changed |= RewriteInstrIfNeeded(*BBID);
2432 BBID->moveBefore(BB->getFirstInsertionPt());
2445 Inc->eraseFromParent();
2448 RewriteInstrIfNeeded(*Inc);
2450 }
else if (Inc != BBID) {
2455 Inc->eraseFromParent();
2459 Changed |= RewriteCallsiteInsIfNeeded(*CS);
2464 if (Seen.
insert(Succ).second)
2465 Worklist.push_back(Succ);
2469 "Counter index mapping should be either to -1 or to non-zero index, "
2471 "index corresponds to the entry BB of the caller");
2473 "Callsite index mapping should be either to -1 or to non-zero index, "
2474 "because there should have been at least a callsite - the inlined one "
2475 "- which would have had a 0 index.");
2477 return {std::move(CalleeCounterMap), std::move(CalleeCallsiteMap)};
2497 AAResults *CalleeAAR,
bool InsertLifetime,
2498 bool TrackInlineHistory,
Function *ForwardVarArgsTo,
2501 return InlineFunction(CB, IFI, MergeAttributes, CalleeAAR, InsertLifetime,
2502 TrackInlineHistory, ForwardVarArgsTo, ORE);
2511 const auto CalleeGUID = Callee.getGUID();
2514 static_cast<uint32_t>(CallsiteIDIns->getIndex()->getZExtValue());
2519 auto Ret =
InlineFunction(CB, IFI, MergeAttributes, CalleeAAR, InsertLifetime,
2520 TrackInlineHistory, ForwardVarArgsTo, ORE);
2521 if (!Ret.isSuccess())
2526 CallsiteIDIns->eraseFromParent();
2531 const auto IndicesMaps =
remapIndices(Caller, StartBB, CtxProf,
2532 NumCalleeCounters, NumCalleeCallsites);
2536 assert(Ctx.guid() == Caller.getGUID());
2537 const auto &[CalleeCounterMap, CalleeCallsiteMap] = IndicesMaps;
2539 (Ctx.counters().size() +
2540 llvm::count_if(CalleeCounterMap, [](
auto V) { return V != -1; }) ==
2542 "The caller's counters size should have grown by the number of new "
2543 "distinct counters inherited from the inlined callee.");
2544 Ctx.resizeCounters(NewCountersSize);
2548 auto CSIt = Ctx.callsites().find(
CallsiteID);
2549 if (CSIt == Ctx.callsites().end())
2551 auto CalleeCtxIt = CSIt->second.find(CalleeGUID);
2554 if (CalleeCtxIt == CSIt->second.end())
2559 auto &CalleeCtx = CalleeCtxIt->second;
2560 assert(CalleeCtx.guid() == CalleeGUID);
2562 for (
auto I = 0U;
I < CalleeCtx.counters().
size(); ++
I) {
2563 const int64_t NewIndex = CalleeCounterMap[
I];
2564 if (NewIndex >= 0) {
2565 assert(NewIndex != 0 &&
"counter index mapping shouldn't happen to a 0 "
2566 "index, that's the caller's entry BB");
2567 Ctx.counters()[NewIndex] = CalleeCtx.counters()[
I];
2570 for (
auto &[
I, OtherSet] : CalleeCtx.callsites()) {
2571 const int64_t NewCSIdx = CalleeCallsiteMap[
I];
2572 if (NewCSIdx >= 0) {
2574 "callsite index mapping shouldn't happen to a 0 index, the "
2575 "caller must've had at least one callsite (with such an index)");
2576 Ctx.ingestAllContexts(NewCSIdx, std::move(OtherSet));
2586 CtxProf.
update(Updater, Caller);
2609 for (
const auto &
Op : InlineHistory->operands()) {
2611 if (MD->getValue() == CalledFunc) {
2656 "convergent call needs convergencectrl operand");
2667 if (CalledFunc->
hasGC()) {
2668 if (Caller->hasGC() && CalledFunc->
getGC() != Caller->getGC())
2682 Caller->hasPersonalityFn()
2683 ? Caller->getPersonalityFn()->stripPointerCasts()
2685 if (CalledPersonality) {
2690 if (CallerPersonality && CalledPersonality != CallerPersonality)
2696 if (CallerPersonality) {
2699 std::optional<OperandBundleUse> ParentFunclet =
2713 for (
const BasicBlock &CalledBB : *CalledFunc) {
2721 for (
const BasicBlock &CalledBB : *CalledFunc) {
2722 if (CalledBB.isEHPad())
2742 bool MergeAttributes,
AAResults *CalleeAAR,
2743 bool InsertLifetime,
bool TrackInlineHistory,
2750 "CanInlineCallSite should have verified direct call to definition");
2754 bool EHPadForCallUnwindsLocally =
false;
2757 Value *CallSiteUnwindDestToken =
2760 EHPadForCallUnwindsLocally =
2761 CallSiteUnwindDestToken &&
2779 if (CalledFunc->
hasGC()) {
2780 if (!Caller->hasGC())
2781 Caller->setGC(CalledFunc->
getGC());
2784 "CanInlineCallSite should have verified compatible GCs");
2791 if (!Caller->hasPersonalityFn()) {
2792 Caller->setPersonalityFn(CalledPersonality);
2794 assert(Caller->getPersonalityFn()->stripPointerCasts() ==
2795 CalledPersonality &&
2796 "CanInlineCallSite should have verified compatible personality");
2820 auto &
DL = Caller->getDataLayout();
2827 E = CalledFunc->
arg_end();
I != E; ++
I, ++AI, ++ArgNo) {
2828 Value *ActualArg = *AI;
2836 &CB, CalledFunc, IFI,
2838 if (ActualArg != *AI)
2844 VMap[&*
I] = ActualArg;
2864 false, Returns,
".i",
2865 InlinedFunctionInfo);
2867 FirstNewBlock = LastBlock; ++FirstNewBlock;
2882 CalledFunc->
front());
2890 for (ByValInit &
Init : ByValInits)
2892 Caller->getParent(), &*FirstNewBlock, IFI,
2895 std::optional<OperandBundleUse> ParentDeopt =
2922 std::vector<Value *> MergedDeoptArgs;
2923 MergedDeoptArgs.reserve(ParentDeopt->Inputs.size() +
2924 ChildOB.Inputs.size());
2929 OpDefs.
emplace_back(
"deopt", std::move(MergedDeoptArgs));
2960 SAMetadataCloner.clone();
2961 SAMetadataCloner.remap(FirstNewBlock, Caller->end());
2984 if (CalledFunc->
hasMetadata(LLVMContext::MD_implicit_ref)) {
2986 CalledFunc->
getMetadata(LLVMContext::MD_implicit_ref, MDs);
2988 Caller->addMetadata(LLVMContext::MD_implicit_ref, *MD);
2994 FirstNewBlock, Caller->end());
2999 make_range(FirstNewBlock->getIterator(), Caller->end()))
3007 if (IntrinsicCall) {
3020 E = FirstNewBlock->end();
I != E; ) {
3050 Caller->getEntryBlock().splice(
InsertPoint, &*FirstNewBlock,
3067 bool InlinedMustTailCalls =
false, InlinedDeoptimizeCalls =
false;
3071 CallSiteTailKind = CI->getTailCallKind();
3086 if (!VarArgsToForward.
empty() &&
3087 ((ForwardVarArgsTo &&
3093 if (!Attrs.isEmpty() || !VarArgsAttrs.
empty()) {
3094 for (
unsigned ArgNo = 0;
3096 ArgAttrs.
push_back(Attrs.getParamAttrs(ArgNo));
3101 Attrs = AttributeList::get(CI->
getContext(), Attrs.getFnAttrs(),
3102 Attrs.getRetAttrs(), ArgAttrs);
3118 InlinedDeoptimizeCalls |=
3119 F->getIntrinsicID() == Intrinsic::experimental_deoptimize;
3138 ChildTCK = std::min(CallSiteTailKind, ChildTCK);
3157 if ((InsertLifetime || Caller->isPresplitCoroutine()) &&
3178 if (InlinedMustTailCalls &&
3179 RI->
getParent()->getTerminatingMustTailCall())
3181 if (InlinedDeoptimizeCalls &&
3182 RI->
getParent()->getTerminatingDeoptimizeCall())
3194 IRBuilder<>(FirstNewBlock->begin()).CreateStackSave(
"savedstack");
3201 if (InlinedMustTailCalls && RI->
getParent()->getTerminatingMustTailCall())
3203 if (InlinedDeoptimizeCalls && RI->
getParent()->getTerminatingDeoptimizeCall())
3238 if (CleanupRet->unwindsToCaller() && EHPadForCallUnwindsLocally)
3256 if (InlinedDeoptimizeCalls) {
3262 if (Caller->getReturnType() == CB.
getType()) {
3264 return RI->
getParent()->getTerminatingDeoptimizeCall() !=
nullptr;
3269 Caller->getParent(), Intrinsic::experimental_deoptimize,
3270 {Caller->getReturnType()});
3296 "Expected at least the deopt operand bundle");
3300 Builder.CreateCall(NewDeoptIntrinsic, CallArgs, OpBundles);
3304 Builder.CreateRetVoid();
3306 Builder.CreateRet(NewDeoptCall);
3321 if (InlinedMustTailCalls) {
3326 RI->
getParent()->getTerminatingMustTailCall();
3327 if (!ReturnedMustTail)
3344 make_range(FirstNewBlock->getIterator(), Caller->end()))
3356 if (TrackInlineHistory ||
3364 for (
const auto &
Op : CBHistory->operands()) {
3370 ICB->
getMetadata(LLVMContext::MD_inline_history)) {
3371 for (
const auto &
Op : CBHistory->operands()) {
3377 ICB->
setMetadata(LLVMContext::MD_inline_history, NewHistory);
3384 if (Returns.
size() == 1 && std::distance(FirstNewBlock, Caller->end()) == 1) {
3387 FirstNewBlock->end());
3389 Caller->back().eraseFromParent();
3403 if (&CB == R->getReturnValue())
3412 Returns[0]->eraseFromParent();
3414 if (MergeAttributes)
3415 AttributeFuncs::mergeAttributesForInlining(*Caller, *CalledFunc);
3432 CreatedBranchToNormalDest =
3442 CalledFunc->
getName() +
".exit");
3449 CalledFunc->
getName() +
".exit");
3467 Caller->splice(AfterCallBB->
getIterator(), Caller, FirstNewBlock,
3475 if (Returns.
size() > 1) {
3480 PHI->insertBefore(AfterCallBB->
begin());
3491 "Ret value not consistent in function!");
3492 PHI->addIncoming(RI->getReturnValue(), RI->
getParent());
3508 if (CreatedBranchToNormalDest)
3510 }
else if (!Returns.
empty()) {
3514 if (&CB == Returns[0]->getReturnValue())
3521 BasicBlock *ReturnBB = Returns[0]->getParent();
3526 AfterCallBB->
splice(AfterCallBB->
begin(), ReturnBB);
3528 if (CreatedBranchToNormalDest)
3532 Returns[0]->eraseFromParent();
3539 if (CreatedBranchToNormalDest)
3551 if (InlinedMustTailCalls &&
pred_empty(AfterCallBB))
3575 auto &
DL = Caller->getDataLayout();
3577 PHI->replaceAllUsesWith(V);
3578 PHI->eraseFromParent();
3582 if (MergeAttributes)
3583 AttributeFuncs::mergeAttributesForInlining(*Caller, *CalledFunc);
3588 AAResults *CalleeAAR,
bool InsertLifetime,
bool TrackInlineHistory,
3591 if (Result.isSuccess()) {
3593 TrackInlineHistory, ForwardVarArgsTo, ORE);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the simple types necessary to represent the attributes associated with functions a...
static void UpdatePHINodes(BasicBlock *OrigBB, BasicBlock *NewBB, ArrayRef< BasicBlock * > Preds, Instruction *BI, bool HasLoopExit)
Update the PHI nodes in OrigBB to include the values coming from NewBB.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
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.
static AttrBuilder IdentifyValidUBGeneratingAttributes(CallBase &CB)
DenseMap< Instruction *, Value * > UnwindDestMemoTy
static at::StorageToVarsMap collectEscapedLocals(const DataLayout &DL, const CallBase &CB)
Find Alloca and linked DbgAssignIntrinsic for locals escaped by CB.
static void fixupLineNumbers(Function *Fn, Function::iterator FI, Instruction *TheCall, bool CalleeHasDebugInfo)
Update inlined instructions' line numbers to to encode location where these instructions are inlined.
static void removeCallsiteMetadata(CallBase *Call)
static void PropagateInlinedFromMetadata(CallBase &CB, StringRef CalledFuncName, StringRef CallerFuncName, Function::iterator FStart, Function::iterator FEnd)
Track inlining chain via inlined.from metadata for dontcall diagnostics.
static Value * getUnwindDestToken(Instruction *EHPad, UnwindDestMemoTy &MemoMap)
Given an EH pad, find where it unwinds.
static void propagateMemProfMetadata(Function *Callee, CallBase &CB, bool ContainsMemProfMetadata, const ValueMap< const Value *, WeakTrackingVH > &VMap, OptimizationRemarkEmitter *ORE)
static cl::opt< bool > PreserveAlignmentAssumptions("preserve-alignment-assumptions-during-inlining", cl::init(false), cl::Hidden, cl::desc("Convert align attributes to assumptions during inlining."))
static void HandleInlinedLandingPad(InvokeInst *II, BasicBlock *FirstNewBlock, ClonedCodeInfo &InlinedCodeInfo)
If we inlined an invoke site, we need to convert calls in the body of the inlined function into invok...
static Value * getUnwindDestTokenHelper(Instruction *EHPad, UnwindDestMemoTy &MemoMap)
Helper for getUnwindDestToken that does the descendant-ward part of the search.
static void updateCallProfile(Function *Callee, const ValueToValueMapTy &VMap, const uint64_t &CalleeEntryCount, const CallBase &TheCall, ProfileSummaryInfo *PSI, BlockFrequencyInfo *CallerBFI)
Update the branch metadata for cloned call instructions.
static cl::opt< bool > UseNoAliasIntrinsic("use-noalias-intrinsic-during-inlining", cl::Hidden, cl::init(true), cl::desc("Use the llvm.experimental.noalias.scope.decl " "intrinsic during inlining."))
static void propagateAllocTokenMetadata(Function *CalledFunc, CallBase &CB, const ValueMap< const Value *, WeakTrackingVH > &VMap, ClonedCodeInfo &InlinedFunctionInfo)
When inlining a call that carries !alloc_token metadata, propagate that metadata onto calls exposed b...
static void inlineRetainOrClaimRVCalls(CallBase &CB, objcarc::ARCInstKind RVCallKind, const SmallVectorImpl< ReturnInst * > &Returns, ClonedCodeInfo &InlinedFunctionInfo)
An operand bundle "clang.arc.attachedcall" on a call indicates the call result is implicitly consumed...
static DebugLoc inlineDebugLoc(DebugLoc OrigDL, DILocation *InlinedAt, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &IANodes, SmallDenseMap< const DILocation *, DILocation *, 16 > &InlineLocs)
Returns a DebugLoc for a new DILocation which is a clone of OrigDL inlined at InlinedAt.
static void PropagateCallSiteMetadata(CallBase &CB, Function::iterator FStart, Function::iterator FEnd)
When inlining a call site that has !llvm.mem.parallel_loop_access, !llvm.access.group,...
static std::pair< std::vector< int64_t >, std::vector< int64_t > > remapIndices(Function &Caller, BasicBlock *StartBB, PGOContextualProfile &CtxProf, uint32_t CalleeCounters, uint32_t CalleeCallsites)
static AttrBuilder IdentifyValidPoisonGeneratingAttributes(CallBase &CB)
static void updateMemprofMetadata(CallBase *CI, const std::vector< Metadata * > &MIBList, OptimizationRemarkEmitter *ORE)
static void updateCallerBFI(BasicBlock *CallSiteBlock, const ValueToValueMapTy &VMap, BlockFrequencyInfo *CallerBFI, BlockFrequencyInfo *CalleeBFI, const BasicBlock &CalleeEntryBlock)
Update the block frequencies of the caller after a callee has been inlined.
static void AddReturnAttributes(CallBase &CB, ValueToValueMapTy &VMap, ClonedCodeInfo &InlinedFunctionInfo)
static void HandleByValArgumentInit(Type *ByValType, Value *Dst, Value *Src, MaybeAlign SrcAlign, Module *M, BasicBlock *InsertBlock, InlineFunctionInfo &IFI, Function *CalledFunc)
static bool MayContainThrowingOrExitingCallAfterCB(CallBase *Begin, ReturnInst *End)
static cl::opt< bool > EnableNoAliasConversion("enable-noalias-to-md-conversion", cl::init(true), cl::Hidden, cl::desc("Convert noalias attributes to metadata during inlining."))
static void AddAliasScopeMetadata(CallBase &CB, ValueToValueMapTy &VMap, const DataLayout &DL, AAResults *CalleeAAR, ClonedCodeInfo &InlinedFunctionInfo)
If the inlined function has noalias arguments, then add new alias scopes for each noalias argument,...
static IntrinsicInst * getConvergenceEntry(BasicBlock &BB)
static void HandleInlinedEHPad(InvokeInst *II, BasicBlock *FirstNewBlock, ClonedCodeInfo &InlinedCodeInfo)
If we inlined an invoke site, we need to convert calls in the body of the inlined function into invok...
static void collectReturnedCalls(Value *RetVal, SmallVectorImpl< CallBase * > &Out)
Collect the calls whose result RetVal returns as a whole, following casts, phis, selects,...
static void fixupAssignments(Function::iterator Start, Function::iterator End)
Update inlined instructions' DIAssignID metadata.
static void PropagateOperandBundles(Function::iterator InlinedBB, Instruction *CallSiteEHPad, ClonedCodeInfo &InlinedFunctionInfo)
Bundle operands of the inlined function must be added to inlined call sites.
static void propagateMemProfHelper(const CallBase *OrigCall, CallBase *ClonedCall, MDNode *InlinedCallsiteMD, OptimizationRemarkEmitter *ORE)
static bool allocaWouldBeStaticInEntry(const AllocaInst *AI)
Return the result of AI->isStaticAlloca() if AI were moved to the entry block.
static BasicBlock * HandleCallsInBlockInlinedThroughInvoke(BasicBlock *BB, BasicBlock *UnwindEdge, ClonedCodeInfo &InlinedCodeInfo, UnwindDestMemoTy *FuncletUnwindMap=nullptr)
When we inline a basic block into an invoke, we have to turn all of the calls that can throw into inv...
static void removeMemProfMetadata(CallBase *Call)
static Value * HandleByValArgument(Type *ByValType, Value *Arg, Instruction *TheCall, const Function *CalledFunc, InlineFunctionInfo &IFI, MaybeAlign ByValAlignment)
When inlining a call site that has a byval argument, we have to make the implicit memcpy explicit by ...
static void AddAlignmentAssumptions(CallBase &CB, InlineFunctionInfo &IFI)
If the inlined function has non-byval align arguments, then add @llvm.assume-based alignment assumpti...
static void trackInlinedStores(Function::iterator Start, Function::iterator End, const CallBase &CB)
static cl::opt< unsigned > InlinerAttributeWindow("max-inst-checked-for-throw-during-inlining", cl::Hidden, cl::desc("the maximum number of instructions analyzed for may throw during " "attribute inference in inlined body"), cl::init(4))
static void AddParamAndFnBasicAttributes(const CallBase &CB, ValueToValueMapTy &VMap, ClonedCodeInfo &InlinedFunctionInfo)
static bool haveCommonPrefix(MDNode *MIBStackContext, MDNode *CallsiteStackContext)
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static cl::opt< bool > NoAliases("loongarch-no-aliases", cl::desc("Disable the emission of assembler pseudo instructions"), cl::init(false), cl::Hidden)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
This file defines common analysis utilities used by the ObjC ARC Optimizer.
This file defines ARC utility functions which are used by various parts of the compiler.
This file contains the declarations for profiling metadata utility functions.
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
static Value * getParentPad(Value *EHPad)
LLVM_ABI MemoryEffects getMemoryEffects(const CallBase *Call)
Return the behavior of the given call site.
Class for arbitrary precision integers.
an instruction to allocate memory on the stack
bool isSwiftError() const
Return true if this alloca is used as a swifterror argument to a call.
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
LLVM_ABI std::optional< TypeSize > getAllocationSize(const DataLayout &DL) const
Get allocation size in bytes.
const Value * getArraySize() const
Get the number of elements allocated.
This class represents an incoming formal argument to a Function.
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
A cache of @llvm.assume calls within a function.
LLVM_ABI void registerAssumption(AssumeInst *CI)
Add an @llvm.assume intrinsic to this function's cache.
An instruction that atomically checks whether a specified value is in a memory location,...
an instruction that atomically reads a memory location, combines it with another value,...
static LLVM_ABI AttributeSet get(LLVMContext &C, const AttrBuilder &B)
Functions, function parameters, and return types can have attributes to indicate how they should be t...
LLVM_ABI const ConstantRange & getRange() const
Returns the value of the range attribute.
LLVM_ABI FPClassTest getNoFPClass() const
Return the FPClassTest for nofpclass.
bool isValid() const
Return true if the attribute is any kind of attribute.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
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.
LLVM_ABI InstListType::const_iterator getFirstNonPHIIt() const
Returns an iterator to the first instruction in this block that is not a PHINode instruction.
LLVM_ABI SymbolTableList< BasicBlock >::iterator eraseFromParent()
Unlink 'this' from the containing function and delete it.
InstListType::iterator iterator
Instruction iterators...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
void splice(BasicBlock::iterator ToIt, BasicBlock *FromBB)
Transfer all instructions from FromBB to this basic block at ToIt.
LLVM_ABI void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Update PHI nodes in this BasicBlock before removal of predecessor Pred.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
LLVM_ABI void setBlockFreq(const BasicBlock *BB, BlockFrequency Freq)
LLVM_ABI void setBlockFreqAndScale(const BasicBlock *ReferenceBB, BlockFrequency Freq, SmallPtrSetImpl< BasicBlock * > &BlocksToScale)
Set the frequency of ReferenceBB to Freq and scale the frequencies of the blocks in BlocksToScale suc...
LLVM_ABI BlockFrequency getBlockFreq(const BasicBlock *BB) const
getblockFreq - Return block frequency.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
void setCallingConv(CallingConv::ID CC)
LLVM_ABI FPClassTest getRetNoFPClass() const
Extract a test mask for disallowed floating-point value classes for the return value.
MaybeAlign getRetAlign() const
Extract the alignment of the return value.
LLVM_ABI void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
OperandBundleUse getOperandBundleAt(unsigned Index) const
Return the operand bundle at a specific index.
std::optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Return an operand bundle by name, if present.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
void removeRetAttrs(const AttributeMask &AttrsToRemove)
Removes the attributes from the return value.
bool hasRetAttr(Attribute::AttrKind Kind) const
Determine whether the return value has the given attribute.
unsigned getNumOperandBundles() const
Return the number of operand bundles associated with this User.
CallingConv::ID getCallingConv() const
LLVM_ABI bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Get the attribute of a given kind from a given arg.
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
static LLVM_ABI CallBase * addOperandBundle(CallBase *CB, uint32_t ID, OperandBundleDef OB, InsertPosition InsertPt=nullptr)
Create a clone of CB with operand bundle OB added.
MaybeAlign getParamAlign(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
AttributeSet getRetAttributes() const
Return the return attributes for this call.
Type * getParamByValType(unsigned ArgNo) const
Extract the byval type for a call or parameter.
Value * getCalledOperand() const
void setAttributes(AttributeList A)
Set the attributes for this call.
LLVM_ABI std::optional< ConstantRange > getRange() const
If this return value has a range attribute, return the value range of the argument.
bool doesNotThrow() const
Determine if the call cannot unwind.
Value * getArgOperand(unsigned i) const
uint64_t getRetDereferenceableBytes() const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
bool isConvergent() const
Determine if the invoke is convergent.
FunctionType * getFunctionType() const
static LLVM_ABI CallBase * Create(CallBase *CB, ArrayRef< OperandBundleDef > Bundles, InsertPosition InsertPt=nullptr)
Create a clone of CB with a different set of operand bundles and insert it before InsertPt.
uint64_t getRetDereferenceableOrNullBytes() const
Extract the number of dereferenceable_or_null bytes for a call (0=unknown).
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
unsigned arg_size() const
AttributeList getAttributes() const
Return the attributes for this call.
bool hasOperandBundles() const
Return true if this User has any operand bundles.
LLVM_ABI Function * getCaller()
Helper to get the caller (the parent function).
This class represents a function call, abstracting a target machine's calling convention.
void setTailCallKind(TailCallKind TCK)
TailCallKind getTailCallKind() const
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
bool isMustTailCall() const
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB=nullptr, InsertPosition InsertBefore=nullptr)
This class represents a range of values.
LLVM_ABI ConstantRange intersectWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the intersection of this range with another range.
static LLVM_ABI ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
This is an important base class in LLVM.
const Constant * stripPointerCasts() const
static LLVM_ABI InstrProfIncrementInst * getBBInstrumentation(BasicBlock &BB)
Get the instruction instrumenting a BB, or nullptr if not present.
static LLVM_ABI InstrProfCallsite * getCallsiteInstrumentation(CallBase &CB)
Get the instruction instrumenting a callsite, or nullptr if that cannot be found.
const DILocation * getWithoutAtom() const
static bool isPseudoProbeDiscriminator(unsigned Discriminator)
uint64_t getAtomGroup() const
const DILocation * cloneWithDiscriminator(unsigned Discriminator) const
Returns a new DILocation with updated Discriminator.
Metadata * getRawIRLayers() const
The optional intermediate-IR layer list (DILayerLocList), or null.
uint8_t getAtomRank() const
Subprogram description. Uses SubclassData1.
A parsed version of the target data layout string in and methods for querying it.
Base class for non-instruction debug metadata records that have positions within IR.
Record of a variable value-assignment, aka a non instruction representation of the dbg....
static DebugLoc getCompilerGenerated()
LLVM_ABI unsigned getLine() const
DILocation * get() const
Get the underlying DILocation.
LLVM_ABI MDNode * getScope() const
static LLVM_ABI DebugLoc appendInlinedAt(const DebugLoc &DL, DILocation *InlinedAt, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &Cache)
Rebuild the entire inlined-at chain for this instruction so that the top of the chain now is inlined-...
LLVM_ABI MDNode * getRawIRLayers() const
The raw intermediate-IR layer list (DILayerLocList) of the underlying location, or null.
static DebugLoc getTemporary()
LLVM_ABI unsigned getCol() const
LLVM_ABI bool isImplicitCode() const
Check if the DebugLoc corresponds to an implicit code.
static DebugLoc getUnknown()
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
iterator find(const_arg_type_t< KeyT > Val)
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.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Implements a dense probed hash-table based set.
void recalculate(ParentType &Func)
recalculate - compute a dominator tree for the given function
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
const BasicBlock & getEntryBlock() const
BasicBlockListType::iterator iterator
FunctionType * getFunctionType() const
Returns the FunctionType for me.
const BasicBlock & front() const
iterator_range< arg_iterator > args()
DISubprogram * getSubprogram() const
Get the attached subprogram.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool hasPersonalityFn() const
Check whether this function has a personality function.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
MaybeAlign getParamAlign(unsigned ArgNo) const
std::optional< uint64_t > getEntryCount() const
Get the entry count for this function.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
const std::string & getGC() const
Type * getReturnType() const
Returns the type of the ret val.
void setCallingConv(CallingConv::ID CC)
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
bool hasMetadata() const
Return true if this GlobalObject has any metadata attached to it.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this GlobalObject.
LLVM_ABI bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
LLVM_ABI CallInst * CreateLifetimeStart(Value *Ptr)
Create a lifetime.start intrinsic.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
This class captures the data input to the InlineFunction call, and records the auxiliary results prod...
Value * ConvergenceControlToken
bool UpdateProfile
Update profile for callee as well as cloned version.
Instruction * CallSiteEHPad
function_ref< AssumptionCache &(Function &)> GetAssumptionCache
If non-null, InlineFunction will update the callgraph to reflect the changes it makes.
BlockFrequencyInfo * CalleeBFI
SmallVector< AllocaInst *, 4 > StaticAllocas
InlineFunction fills this in with all static allocas that get copied into the caller.
BlockFrequencyInfo * CallerBFI
SmallVector< CallBase *, 8 > InlinedCallSites
All of the new call sites inlined into the caller.
InlineResult is basically true or false.
static InlineResult success()
static InlineResult failure(const char *Reason)
This represents the llvm.instrprof.callsite intrinsic.
This represents the llvm.instrprof.increment intrinsic.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
LLVM_ABI const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
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.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
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 const DataLayout & getDataLayout() const
Get the data layout of the module this instruction belongs to.
A wrapper class for inspecting calls to intrinsic functions.
static LLVM_ABI bool mayLowerToFunctionCall(Intrinsic::ID IID)
Check if the intrinsic might lower into a regular function call in the course of IR transformations.
This is an important class for using LLVM in a threaded context.
@ OB_clang_arc_attachedcall
The landingpad instruction holds all of the information necessary to generate correct exception handl...
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
An instruction for reading from memory.
MDNode * createAnonymousAliasScope(MDNode *Domain, StringRef Name=StringRef())
Return metadata appropriate for an alias scope root node.
LLVM_ABI MDNode * createAnonymousAliasScopeDomain(StringRef Description=StringRef(), bool DisjointScopes=false)
Return metadata appropriate for an alias scope domain node, described by Description,...
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
void replaceAllUsesWith(Metadata *MD)
RAUW a temporary.
static LLVM_ABI MDNode * concatenate(MDNode *A, MDNode *B)
Methods for metadata merging.
ArrayRef< MDOperand > operands() const
op_iterator op_end() const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
unsigned getNumOperands() const
Return number of MDNode operands.
op_iterator op_begin() const
LLVMContext & getContext() const
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a temporary node.
bool onlyAccessesInaccessibleMem() const
Whether this function only (at most) accesses inaccessible memory.
bool onlyAccessesArgPointees() const
Whether this function only (at most) accesses argument memory.
A Module instance is used to store all the information related to an LLVM module.
The instrumented contextual profile, produced by the CtxProfAnalysis.
LLVM_ABI bool isInSpecializedModule() const
LLVM_ABI void update(Visitor, const Function &F)
uint32_t getNumCounters(const Function &F) const
uint32_t allocateNextCounterIndex(const Function &F)
uint32_t getNumCallsites(const Function &F) const
uint32_t allocateNextCallsiteIndex(const Function &F)
A node (context) in the loaded contextual profile, suitable for mutation during IPO passes.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
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 PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Analysis providing profile information.
LLVM_ABI std::optional< uint64_t > getProfileCount(const CallBase &CallInst, BlockFrequencyInfo *BFI) const
Returns the profile count for CallInst.
Resume the propagation of an exception.
Return a value (possibly void), from a function.
bool insert(const value_type &X)
Insert a new element into the SetVector.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
void insert_range(Range &&R)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
LLVM_NO_SANITIZE_CFI_UNRELATED_CAST iterator begin()
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
bool isVoidTy() const
Return true if this is 'void'.
Unconditional Branch instruction.
void setSuccessor(BasicBlock *NewSucc)
static UncondBrInst * Create(BasicBlock *Target, InsertPosition InsertBefore=nullptr)
BasicBlock * getSuccessor(unsigned i=0) const
Value * getOperand(unsigned i) const
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
ValueT lookup(const KeyT &Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
size_type count(const KeyT &Val) const
Return 1 if the specified key is in the map, 0 otherwise.
ValueMapIteratorImpl< MapT, const Value *, false > iterator
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
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 takeName(Value *V)
Transfer the name from V to this value.
std::pair< iterator, bool > insert(const ValueT &V)
const ParentTy * getParent() const
self_iterator getIterator()
Class to build a trie of call stack contexts for a particular profiled allocation call,...
Helper class to iterate through stack ids in both metadata (memprof MIB and callsite) and the corresp...
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
CallingConv Namespace - This namespace contains an enum with a value for the well-known calling conve...
@ 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.
bool match(Val *V, const Pattern &P)
match_immconstant_ty m_ImmConstant()
Match an arbitrary immediate Constant and ignore it.
LLVM_ABI void trackAssignments(Function::iterator Start, Function::iterator End, const StorageToVarsMap &Vars, const DataLayout &DL, bool DebugPrints=false)
Track assignments to Vars between Start and End.
LLVM_ABI void remapAssignID(DenseMap< DIAssignID *, DIAssignID * > &Map, Instruction &I)
Replace DIAssignID uses and attachments with IDs from Map.
SmallVector< DbgVariableRecord * > getDVRAssignmentMarkers(const Instruction *Inst)
Return a range of dbg_assign records for which Inst performs the assignment they encode.
DenseMap< const AllocaInst *, SmallSetVector< VarRecord, 2 > > StorageToVarsMap
Map of backing storage to a set of variables that are stored to it.
initializer< Ty > init(const Ty &Val)
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract(Y &&MD)
Extract a Value from Metadata, if any.
LLVM_ABI MDNode * getMIBStackNode(const MDNode *MIB)
Returns the stack node from an MIB metadata node.
ARCInstKind getAttachedARCFunctionKind(const CallBase *CB)
This function returns the ARCInstKind of the function attached to operand bundle clang_arc_attachedca...
ARCInstKind
Equivalence classes of instructions in the ARC Model.
@ None
anything that is inert from an ARC perspective.
@ UnsafeClaimRV
objc_unsafeClaimAutoreleasedReturnValue
std::optional< Function * > getAttachedARCFunction(const CallBase *CB)
This function returns operand bundle clang_arc_attachedcall's argument, which is the address of the A...
bool isRetainOrClaimRV(ARCInstKind Kind)
Check whether the function is retainRV/claimRV/unsafeClaimRV.
const Value * GetRCIdentityRoot(const Value *V)
The RCIdentity root of a value V is a dominating value U for which retaining or releasing U is equiva...
bool hasAttachedCallOpBundle(const CallBase *CB)
This is an optimization pass for GlobalISel generic memory operations.
UnaryFunction for_each(R &&Range, UnaryFunction F)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
LLVM_ABI Value * simplifyInstruction(Instruction *I, const SimplifyQuery &Q, SmallVectorImpl< Instruction * > *DropAnnotations=nullptr)
See if we can compute a simplified version of this instruction.
LLVM_ABI BasicBlock * changeToInvokeAndSplitBasicBlock(CallInst *CI, BasicBlock *UnwindEdge, DomTreeUpdater *DTU=nullptr)
Convert the CallInst to InvokeInst with the specified unwind edge basic block.
LLVM_ABI Align getOrEnforceKnownAlignment(Value *V, MaybeAlign PrefAlign, const DataLayout &DL, const Instruction *CtxI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
Try to ensure that the alignment of V is at least PrefAlign bytes.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto successors(const MachineBasicBlock *BB)
LLVM_ABI void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix, ClonedCodeInfo &CodeInfo)
This works exactly like CloneFunctionInto, except that it does some simple constant prop and DCE on t...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
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...
std::string utostr(uint64_t X, bool isNeg=false)
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
LLVM_ABI Value * FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB, BasicBlock::iterator &ScanFrom, unsigned MaxInstsToScan=DefMaxInstsToScan, BatchAAResults *AA=nullptr, bool *IsLoadCSE=nullptr, unsigned *NumScanedInst=nullptr)
Scan backwards to see if we have the value of the given load available locally within a small number ...
bool isa_and_nonnull(const Y &Val)
LLVM_ABI InlineResult InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, bool MergeAttributes=false, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true, bool TrackInlineHistory=false, Function *ForwardVarArgsTo=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
This function inlines the called function into the basic block of the caller.
LLVM_ABI bool PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures, const Instruction *I, const DominatorTree *DT, bool IncludeI=false, unsigned MaxUsesToExplore=0, const LoopInfo *LI=nullptr)
PointerMayBeCapturedBefore - Return true if this pointer value may be captured by the enclosing funct...
LLVM_ABI InlineResult CanInlineCallSite(const CallBase &CB, InlineFunctionInfo &IFI)
Check if it is legal to perform inlining of the function called by CB into the caller at this particu...
bool isScopedEHPersonality(EHPersonality Pers)
Returns true if this personality uses scope-style EH IR instructions: catchswitch,...
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.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
IRBuilder(LLVMContext &, FolderTy, InserterTy) -> IRBuilder< FolderTy, InserterTy >
LLVM_ABI EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
LLVM_ABI const Value * getUnderlyingObject(const Value *V, unsigned MaxLookup=MaxLookupSearchDepth, bool MustPreserveProvenance=false)
This method strips off any GEP address adjustments, pointer casts or llvm.threadlocal....
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 unsigned changeToUnreachable(Instruction *I, bool PreserveLCSSA=false, DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr)
Insert an unreachable instruction before the specified instruction, making it and the rest of the cod...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_ABI bool salvageKnowledge(Instruction *I, AssumptionCache *AC=nullptr, DominatorTree *DT=nullptr)
Calls BuildAssumeFromInst and if the resulting llvm.assume is valid insert if before I.
LLVM_ABI void updateProfileCallee(Function *Callee, int64_t EntryDelta, const ValueMap< const Value *, WeakTrackingVH > *VMap=nullptr)
Updates profile information by adjusting the entry count by adding EntryDelta then scaling callsite i...
OperandBundleDefT< Value * > OperandBundleDef
LLVM_ABI bool isAssignmentTrackingEnabled(const Module &M)
Return true if assignment tracking is enabled for module M.
LLVM_ABI void InlineFunctionImpl(CallBase &CB, InlineFunctionInfo &IFI, bool MergeAttributes=false, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true, bool TrackInlineHistory=false, Function *ForwardVarArgsTo=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
This should generally not be used, use InlineFunction instead.
LLVM_ABI MDNode * uniteAccessGroups(MDNode *AccGroups1, MDNode *AccGroups2)
Compute the union of two access-group lists.
DWARFExpression::Operation Op
bool isAsynchronousEHPersonality(EHPersonality Pers)
Returns true if this personality function catches asynchronous exceptions.
ValueMap< const Value *, WeakTrackingVH > ValueToValueMapTy
LLVM_ABI bool isGuaranteedToTransferExecutionToSuccessor(const Instruction *I)
Return true if this function can prove that the instruction I will always transfer execution to one o...
LLVM_ABI bool isEscapeSource(const Value *V)
Returns true if the pointer is one which would have been considered an escape by isNotCapturedBefore.
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Align getKnownAlignment(Value *V, const DataLayout &DL, const Instruction *CtxI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
Try to infer an alignment for the specified pointer.
bool capturesAnything(CaptureComponents CC)
bool pred_empty(const BasicBlock *BB)
@ End
Run the machine verifier once, at the end of the pipeline.
LLVM_ABI void getUnderlyingObjects(const Value *V, SmallVectorImpl< const Value * > &Objects, const LoopInfo *LI=nullptr, unsigned MaxLookup=MaxLookupSearchDepth)
This method is similar to getUnderlyingObject except that it can look through phi and select instruct...
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 bool isIdentifiedObject(const Value *V)
Return true if this pointer refers to a distinct and identifiable object.
LLVM_ABI void scaleProfData(Instruction &I, uint64_t S, uint64_t T)
Scaling the profile data attached to 'I' using the ratio of S/T.
constexpr detail::IsaCheckPredicate< Types... > IsaPred
Function object wrapper for the llvm::isa type check.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This struct is a compact representation of a valid (non-zero power of two) alignment.
This struct can be used to capture information about code being cloned, while it is being cloned.
bool ContainsDynamicAllocas
This is set to true if the cloned code contains a 'dynamic' alloca.
bool removeOriginallyIndirectCall(const Value *V)
bool isOriginallyIndirectCall(const Value *V) const
bool isSimplified(const Value *From, const Value *To) const
bool ContainsCalls
This is set to true if the cloned code contains a normal call instruction.
SmallDenseSet< AssertingVH< const Value >, 4 > OriginallyIndirectCalls
bool ContainsMemProfMetadata
This is set to true if there is memprof related metadata (memprof or callsite metadata) in the cloned...
void replaceOriginallyIndirectCall(const Value *Old, const Value *New)
std::vector< WeakTrackingVH > OperandBundleCallSites
All cloned call sites that have operand bundles attached are appended to this vector.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
static Instruction * tryGetVTableInstruction(CallBase *CB)
static std::optional< uint32_t > extractDwarfBaseDiscriminator(uint32_t Value)
Helper struct for trackAssignments, below.