80 cl::desc(
"Convert noalias attributes to metadata during inlining."));
85 cl::desc(
"Convert align attributes to assumptions during inlining."));
89 bool InsertLifetime) {
96 class LandingPadInliningInfo {
107 PHINode *InnerEHValuesPHI =
nullptr;
119 for (; isa<PHINode>(
I); ++
I) {
125 CallerLPad = cast<LandingPadInst>(
I);
131 return OuterResumeDest;
148 void addIncomingPHIValuesFor(
BasicBlock *BB)
const {
149 addIncomingPHIValuesForInto(BB, OuterResumeDest);
154 for (
unsigned i = 0,
e = UnwindDestPHIValues.
size(); i !=
e; ++i, ++
I) {
164 BasicBlock *LandingPadInliningInfo::getInnerResumeDest() {
165 if (InnerResumeDest)
return InnerResumeDest;
170 OuterResumeDest->splitBasicBlock(SplitPoint,
171 OuterResumeDest->getName() +
".body");
174 const unsigned PHICapacity = 2;
177 Instruction *InsertPoint = &InnerResumeDest->front();
179 for (
unsigned i = 0,
e = UnwindDestPHIValues.size(); i !=
e; ++i, ++
I) {
180 PHINode *OuterPHI = cast<PHINode>(
I);
182 OuterPHI->
getName() +
".lpad-body",
185 InnerPHI->addIncoming(OuterPHI, OuterResumeDest);
190 "eh.lpad-body", InsertPoint);
192 InnerEHValuesPHI->addIncoming(CallerLPad, OuterResumeDest);
195 return InnerResumeDest;
202 void LandingPadInliningInfo::forwardResume(
211 addIncomingPHIValuesForInto(Src, Dest);
213 InnerEHValuesPHI->addIncoming(RI->
getOperand(0), Src);
219 if (
auto *FPI = dyn_cast<FuncletPadInst>(EHPad))
220 return FPI->getParentPad();
232 while (!Worklist.
empty()) {
239 Value *UnwindDestToken =
nullptr;
240 if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(CurrentPad)) {
241 if (CatchSwitch->hasUnwindDest()) {
242 UnwindDestToken = CatchSwitch->getUnwindDest()->getFirstNonPHI();
250 for (
auto HI = CatchSwitch->handler_begin(),
251 HE = CatchSwitch->handler_end();
252 HI != HE && !UnwindDestToken; ++
HI) {
254 auto *CatchPad = cast<CatchPadInst>(HandlerBlock->
getFirstNonPHI());
260 if (!isa<CleanupPadInst>(Child) && !isa<CatchSwitchInst>(Child))
264 auto Memo = MemoMap.
find(ChildPad);
265 if (Memo == MemoMap.
end()) {
272 Value *ChildUnwindDestToken = Memo->second;
273 if (!ChildUnwindDestToken)
279 if (isa<ConstantTokenNone>(ChildUnwindDestToken)) {
280 UnwindDestToken = ChildUnwindDestToken;
288 auto *CleanupPad = cast<CleanupPadInst>(CurrentPad);
290 if (
auto *CleanupRet = dyn_cast<CleanupReturnInst>(U)) {
291 if (
BasicBlock *RetUnwindDest = CleanupRet->getUnwindDest())
292 UnwindDestToken = RetUnwindDest->getFirstNonPHI();
297 Value *ChildUnwindDestToken;
298 if (
auto *Invoke = dyn_cast<InvokeInst>(U)) {
299 ChildUnwindDestToken = Invoke->getUnwindDest()->getFirstNonPHI();
300 }
else if (isa<CleanupPadInst>(U) || isa<CatchSwitchInst>(U)) {
302 auto Memo = MemoMap.
find(ChildPad);
303 if (Memo == MemoMap.
end()) {
310 ChildUnwindDestToken = Memo->second;
311 if (!ChildUnwindDestToken)
320 if (isa<Instruction>(ChildUnwindDestToken) &&
323 UnwindDestToken = ChildUnwindDestToken;
329 if (!UnwindDestToken)
337 if (
auto *UnwindPad = dyn_cast<Instruction>(UnwindDestToken))
340 UnwindParent =
nullptr;
341 bool ExitedOriginalPad =
false;
343 ExitedPad && ExitedPad != UnwindParent;
346 if (isa<CatchPadInst>(ExitedPad))
348 MemoMap[ExitedPad] = UnwindDestToken;
349 ExitedOriginalPad |= (ExitedPad == EHPad);
352 if (ExitedOriginalPad)
353 return UnwindDestToken;
384 if (
auto *CPI = dyn_cast<CatchPadInst>(EHPad))
385 EHPad = CPI->getCatchSwitch();
388 auto Memo = MemoMap.
find(EHPad);
389 if (Memo != MemoMap.
end())
394 assert((UnwindDestToken ==
nullptr) != (MemoMap.
count(EHPad) != 0));
396 return UnwindDestToken;
403 MemoMap[EHPad] =
nullptr;
409 Value *AncestorToken;
414 if (isa<CatchPadInst>(AncestorPad))
423 assert(!MemoMap.
count(AncestorPad) || MemoMap[AncestorPad]);
424 auto AncestorMemo = MemoMap.
find(AncestorPad);
425 if (AncestorMemo == MemoMap.
end()) {
428 UnwindDestToken = AncestorMemo->second;
432 LastUselessPad = AncestorPad;
433 MemoMap[LastUselessPad] =
nullptr;
435 TempMemos.
insert(LastUselessPad);
453 while (!Worklist.
empty()) {
455 auto Memo = MemoMap.
find(UselessPad);
456 if (Memo != MemoMap.
end() && Memo->second) {
484 MemoMap[UselessPad] = UnwindDestToken;
485 if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(UselessPad)) {
486 assert(CatchSwitch->getUnwindDest() ==
nullptr &&
"Expected useless pad");
487 for (
BasicBlock *HandlerBlock : CatchSwitch->handlers()) {
488 auto *CatchPad = HandlerBlock->getFirstNonPHI();
491 (!isa<InvokeInst>(U) ||
493 cast<InvokeInst>(U)->getUnwindDest()->getFirstNonPHI()) ==
495 "Expected useless pad");
496 if (isa<CatchSwitchInst>(U) || isa<CleanupPadInst>(U))
497 Worklist.
push_back(cast<Instruction>(U));
501 assert(isa<CleanupPadInst>(UselessPad));
503 assert(!isa<CleanupReturnInst>(U) &&
"Expected useless pad");
504 assert((!isa<InvokeInst>(U) ||
506 cast<InvokeInst>(U)->getUnwindDest()->getFirstNonPHI()) ==
508 "Expected useless pad");
509 if (isa<CatchSwitchInst>(U) || isa<CleanupPadInst>(U))
510 Worklist.
push_back(cast<Instruction>(U));
515 return UnwindDestToken;
543 if (
F->getIntrinsicID() == Intrinsic::experimental_deoptimize ||
544 F->getIntrinsicID() == Intrinsic::experimental_guard)
555 auto *FuncletPad = cast<Instruction>(FuncletBundle->Inputs[0]);
556 Value *UnwindDestToken =
558 if (UnwindDestToken && !isa<ConstantTokenNone>(UnwindDestToken))
562 if (
auto *CatchPad = dyn_cast<CatchPadInst>(FuncletPad))
563 MemoKey = CatchPad->getCatchSwitch();
565 MemoKey = FuncletPad;
566 assert(FuncletUnwindMap->count(MemoKey) &&
567 (*FuncletUnwindMap)[MemoKey] == UnwindDestToken &&
568 "must get memoized to avoid confusing later searches");
593 LandingPadInliningInfo Invoke(II);
599 if (
InvokeInst *II = dyn_cast<InvokeInst>(
I->getTerminator()))
607 InlinedLPad->reserveClauses(OuterNum);
608 for (
unsigned OuterIdx = 0; OuterIdx != OuterNum; ++OuterIdx)
609 InlinedLPad->addClause(OuterLPad->
getClause(OuterIdx));
611 InlinedLPad->setCleanup(
true);
618 &*BB, Invoke.getOuterResumeDest()))
621 Invoke.addIncomingPHIValuesFor(NewBB);
624 if (
ResumeInst *RI = dyn_cast<ResumeInst>(BB->getTerminator()))
625 Invoke.forwardResume(RI, InlinedLPads);
665 for (
Value *V : UnwindDestPHIValues) {
677 if (
auto *CRI = dyn_cast<CleanupReturnInst>(BB->getTerminator())) {
678 if (CRI->unwindsToCaller()) {
679 auto *CleanupPad = CRI->getCleanupPad();
681 CRI->eraseFromParent();
688 isa<ConstantTokenNone>(FuncletUnwindMap[CleanupPad]));
689 FuncletUnwindMap[CleanupPad] =
699 if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(I)) {
700 if (CatchSwitch->unwindsToCaller()) {
701 Value *UnwindDestToken;
702 if (
auto *ParentPad =
703 dyn_cast<Instruction>(CatchSwitch->getParentPad())) {
713 if (UnwindDestToken && !isa<ConstantTokenNone>(UnwindDestToken))
726 CatchSwitch->getParentPad(), UnwindDest,
727 CatchSwitch->getNumHandlers(), CatchSwitch->getName(),
729 for (
BasicBlock *PadBB : CatchSwitch->handlers())
735 FuncletUnwindMap[NewCatchSwitch] = UnwindDestToken;
736 Replacement = NewCatchSwitch;
738 }
else if (!isa<FuncletPadInst>(I)) {
744 I->replaceAllUsesWith(Replacement);
745 I->eraseFromParent();
755 &*BB, UnwindDest, &FuncletUnwindMap))
764 UnwindDest->removePredecessor(InvokeBB);
776 if (!M && !CallAccessGroup)
780 VMI != VMIE; ++VMI) {
790 NI->
getMetadata(LLVMContext::MD_mem_parallel_loop_access)) {
792 NI->
setMetadata(LLVMContext::MD_mem_parallel_loop_access, M);
794 NI->
setMetadata(LLVMContext::MD_mem_parallel_loop_access, M);
800 NI->
getMetadata(LLVMContext::MD_access_group), CallAccessGroup);
801 NI->
setMetadata(LLVMContext::MD_access_group, UnitedAccGroups);
824 if (
const MDNode *M = J.getMetadata(LLVMContext::MD_alias_scope))
826 if (
const MDNode *M = J.getMetadata(LLVMContext::MD_noalias))
836 while (!Queue.empty()) {
837 const MDNode *M = cast<MDNode>(Queue.pop_back_val());
848 for (
const MDNode *I : MD) {
850 MDMap[
I].reset(DummyNodes.
back().get());
856 for (
const MDNode *I : MD) {
858 for (
unsigned i = 0, ie = I->getNumOperands(); i != ie; ++i) {
859 const Metadata *V = I->getOperand(i);
860 if (
const MDNode *M = dyn_cast<MDNode>(V))
863 NewOps.
push_back(const_cast<Metadata *>(V));
867 MDTuple *TempM = cast<MDTuple>(MDMap[
I]);
868 assert(TempM->isTemporary() &&
"Expected temporary node");
870 TempM->replaceAllUsesWith(NewM);
876 VMI != VMIE; ++VMI) {
892 NI->
setMetadata(LLVMContext::MD_alias_scope, NewMD);
928 if (
Arg.hasNoAliasAttr() && !
Arg.use_empty())
931 if (NoAliasArgs.
empty())
937 DT.
recalculate(const_cast<Function&>(*CalledFunc));
950 MDB.createAnonymousAliasScopeDomain(CalledFunc->
getName());
951 for (
unsigned i = 0,
e = NoAliasArgs.
size(); i !=
e; ++i) {
959 Name +=
": argument ";
966 MDNode *NewScope = MDB.createAnonymousAliasScope(NewDomain, Name);
967 NewScopes.
insert(std::make_pair(A, NewScope));
973 VMI != VMIE; ++VMI) {
974 if (
const Instruction *
I = dyn_cast<Instruction>(VMI->first)) {
982 bool IsArgMemOnlyCall =
false, IsFuncCall =
false;
985 if (
const LoadInst *LI = dyn_cast<LoadInst>(
I))
986 PtrArgs.
push_back(LI->getPointerOperand());
989 else if (
const VAArgInst *VAAI = dyn_cast<VAArgInst>(
I))
990 PtrArgs.
push_back(VAAI->getPointerOperand());
992 PtrArgs.
push_back(CXI->getPointerOperand());
994 PtrArgs.
push_back(RMWI->getPointerOperand());
995 else if (
const auto *Call = dyn_cast<CallBase>(
I)) {
999 if (Call->doesNotAccessMemory())
1007 IsArgMemOnlyCall =
true;
1016 if (IsArgMemOnlyCall && !
Arg->getType()->isPointerTy())
1027 if (PtrArgs.
empty() && !IsFuncCall)
1037 for (
const Value *V : PtrArgs) {
1041 for (
const Value *
O : Objects)
1047 bool CanDeriveViaCapture =
false, UsesAliasingPtr =
false;
1048 for (
const Value *V : ObjSet) {
1052 bool IsNonPtrConst = isa<ConstantInt>(V) || isa<ConstantFP>(V) ||
1053 isa<ConstantPointerNull>(V) ||
1054 isa<ConstantDataVector>(V) || isa<UndefValue>(V);
1061 if (
const Argument *A = dyn_cast<Argument>(V)) {
1062 if (!A->hasNoAliasAttr())
1063 UsesAliasingPtr =
true;
1065 UsesAliasingPtr =
true;
1072 if (!isa<Argument>(V) &&
1074 CanDeriveViaCapture =
true;
1079 if (IsFuncCall && !IsArgMemOnlyCall)
1080 CanDeriveViaCapture =
true;
1090 for (
const Argument *A : NoAliasArgs) {
1091 if (!ObjSet.count(A) && (!CanDeriveViaCapture ||
1104 if (!NoAliases.
empty())
1120 bool CanAddScopes = !UsesAliasingPtr;
1121 if (CanAddScopes && IsFuncCall)
1122 CanAddScopes = IsArgMemOnlyCall;
1125 for (
const Argument *A : NoAliasArgs) {
1126 if (ObjSet.count(A))
1130 if (!Scopes.
empty())
1132 LLVMContext::MD_alias_scope,
1151 bool DTCalculated =
false;
1155 unsigned Align =
Arg.getType()->isPointerTy() ?
Arg.getParamAlignment() : 0;
1156 if (Align && !
Arg.hasByValOrInAllocaAttr() && !
Arg.hasNUses(0)) {
1157 if (!DTCalculated) {
1159 DTCalculated =
true;
1169 .CreateAlignmentAssumption(DL, ArgVal, Align);
1195 if (CalleeNode == CallerNode) {
1196 CallCache.assign(I,
E);
1197 I = CallCache.begin();
1198 E = CallCache.end();
1201 for (; I !=
E; ++
I) {
1202 const Value *OrigCall = I->first;
1206 if (VMI == VMap.
end() || VMI->
second ==
nullptr)
1217 if (NewCall->getCalledFunction() &&
1218 NewCall->getCalledFunction()->isIntrinsic())
1230 if (!I->second->getFunction())
1231 if (
Function *
F = NewCall->getCalledFunction()) {
1249 Type *AggTy = cast<PointerType>(Src->
getType())->getElementType();
1266 unsigned ByValAlignment) {
1280 if (ByValAlignment <= 1)
1318 if (II->isLifetimeStartOrEnd())
1329 if (Ty == Int8PtrTy)
1334 if (U->getType() != Int8PtrTy)
continue;
1335 if (U->stripPointerCasts() != AI)
continue;
1365 "Loop ID needs at least one operand");
1367 "Loop ID should refer to itself");
1375 if (
DILocation *DL = dyn_cast<DILocation>(MD))
1401 Ctx, InlinedAtNode->getLine(), InlinedAtNode->getColumn(),
1402 InlinedAtNode->getScope(), InlinedAtNode->getInlinedAt());
1411 bool NoInlineLineTables = Fn->
hasFnAttribute(
"no-inline-line-tables");
1413 for (; FI != Fn->
end(); ++FI) {
1418 if (
MDNode *LoopID = BI->getMetadata(LLVMContext::MD_loop)) {
1421 BI->setMetadata(LLVMContext::MD_loop, NewLoopID);
1424 if (!NoInlineLineTables)
1425 if (
DebugLoc DL = BI->getDebugLoc()) {
1428 BI->setDebugLoc(IDL);
1432 if (CalleeHasDebugInfo && !NoInlineLineTables)
1442 if (
auto *AI = dyn_cast<AllocaInst>(BI))
1446 BI->setDebugLoc(TheCallDL);
1450 if (NoInlineLineTables) {
1452 while (BI != FI->end()) {
1453 if (isa<DbgInfoIntrinsic>(BI)) {
1454 BI = BI->eraseFromParent();
1476 for (
auto Entry : VMap) {
1477 if (!isa<BasicBlock>(
Entry.first) || !
Entry.second)
1479 auto *OrigBB = cast<BasicBlock>(
Entry.first);
1480 auto *ClonedBB = cast<BasicBlock>(
Entry.second);
1482 if (!ClonedBBs.
insert(ClonedBB).second) {
1492 BasicBlock *EntryClone = cast<BasicBlock>(VMap.lookup(&CalleeEntryBlock));
1509 std::min(CallSiteCount.hasValue() ? CallSiteCount.getValue() : 0,
1515 Function *Callee, int64_t entryDelta,
1518 if (!CalleeCount.hasValue())
1521 uint64_t priorEntryCount = CalleeCount.
getCount();
1522 uint64_t newEntryCount;
1526 if (entryDelta < 0 && static_cast<uint64_t>(-entryDelta) > priorEntryCount)
1529 newEntryCount = priorEntryCount + entryDelta;
1533 uint64_t cloneEntryCount = priorEntryCount - newEntryCount;
1534 for (
auto Entry : *VMap)
1535 if (isa<CallInst>(
Entry.first))
1536 if (
auto *CI = dyn_cast_or_null<CallInst>(
Entry.second))
1537 CI->updateProfWeight(cloneEntryCount, priorEntryCount);
1545 if (!VMap || VMap->
count(&BB))
1547 if (
CallInst *CI = dyn_cast<CallInst>(&
I))
1548 CI->updateProfWeight(newEntryCount, priorEntryCount);
1562 bool InsertLifetime,
1566 &&
"Instruction not in function!");
1569 if (isa<CallBrInst>(TheCall))
1578 return "external or indirect";
1592 return "unsupported operand bundle";
1607 if (CalledFunc->
hasGC()) {
1608 if (!Caller->
hasGC())
1610 else if (CalledFunc->
getGC() != Caller->
getGC())
1611 return "incompatible GC";
1627 if (CalledPersonality) {
1628 if (!CallerPersonality)
1634 else if (CalledPersonality != CallerPersonality)
1635 return "incompatible personality";
1641 if (CallerPersonality) {
1647 CallSiteEHPad = cast<FuncletPadInst>(ParentFunclet->
Inputs.front());
1651 if (CallSiteEHPad) {
1655 if (isa<CleanupPadInst>(CallSiteEHPad)) {
1658 for (
const BasicBlock &CalledBB : *CalledFunc) {
1659 if (isa<CatchSwitchInst>(CalledBB.getFirstNonPHI()))
1660 return "catch in cleanup funclet";
1666 for (
const BasicBlock &CalledBB : *CalledFunc) {
1667 if (CalledBB.isEHPad())
1668 return "SEH in cleanup funclet";
1677 bool EHPadForCallUnwindsLocally =
false;
1678 if (CallSiteEHPad && CS.
isCall()) {
1680 Value *CallSiteUnwindDestToken =
1683 EHPadForCallUnwindsLocally =
1684 CallSiteUnwindDestToken &&
1685 !isa<ConstantTokenNone>(CallSiteUnwindDestToken);
1710 E = CalledFunc->
arg_end();
I !=
E; ++
I, ++AI, ++ArgNo) {
1711 Value *ActualArg = *AI;
1720 if (ActualArg != *AI)
1724 VMap[&*
I] = ActualArg;
1737 false, Returns,
".i",
1738 &InlinedFunctionInfo, TheCall);
1740 FirstNewBlock = LastBlock; ++FirstNewBlock;
1745 CalledFunc->
front());
1751 for (std::pair<Value*, Value*> &
Init : ByValInit)
1753 &*FirstNewBlock, IFI);
1781 std::vector<Value *> MergedDeoptArgs;
1782 MergedDeoptArgs.reserve(ParentDeopt->Inputs.size() +
1783 ChildOB.Inputs.size());
1785 MergedDeoptArgs.insert(MergedDeoptArgs.end(),
1786 ParentDeopt->Inputs.begin(),
1787 ParentDeopt->Inputs.end());
1788 MergedDeoptArgs.insert(MergedDeoptArgs.end(), ChildOB.Inputs.begin(),
1789 ChildOB.Inputs.end());
1791 OpDefs.
emplace_back(
"deopt", std::move(MergedDeoptArgs));
1795 if (isa<CallInst>(I))
1797 else if (isa<CallBrInst>(I))
1835 if (
auto *II = dyn_cast<IntrinsicInst>(&
I))
1836 if (II->getIntrinsicID() == Intrinsic::assume)
1848 E = FirstNewBlock->end();
I !=
E; ) {
1867 while (isa<AllocaInst>(
I) &&
1868 !cast<AllocaInst>(
I)->use_empty() &&
1878 InsertPoint, FirstNewBlock->getInstList(), AI->
getIterator(),
I);
1894 bool InlinedMustTailCalls =
false, InlinedDeoptimizeCalls =
false;
1897 if (
CallInst *CI = dyn_cast<CallInst>(TheCall))
1898 CallSiteTailKind = CI->getTailCallKind();
1906 for (
auto II = BB->begin(); II != BB->end();) {
1914 if (!VarArgsToForward.
empty() &&
1915 ((ForwardVarArgsTo &&
1922 for (
unsigned ArgNo = 0;
1945 InlinedDeoptimizeCalls |=
1946 F->getIntrinsicID() == Intrinsic::experimental_deoptimize;
1965 ChildTCK = std::min(CallSiteTailKind, ChildTCK);
1981 for (
unsigned ai = 0, ae = IFI.
StaticAllocas.size(); ai != ae; ++ai) {
1998 uint64_t AllocaTypeSize = DL.getTypeAllocSize(AllocaType);
1999 uint64_t AllocaArraySize = AIArraySize->getLimitedValue();
2002 if (AllocaArraySize == 0)
2011 AllocaArraySize * AllocaTypeSize);
2015 builder.CreateLifetimeStart(AI, AllocaSize);
2019 if (InlinedMustTailCalls &&
2022 if (InlinedDeoptimizeCalls &&
2025 IRBuilder<>(RI).CreateLifetimeEnd(AI, AllocaSize);
2040 .CreateCall(StackSave, {},
"savedstack");
2051 IRBuilder<>(RI).CreateCall(StackRestore, SavedPtr);
2059 if (
auto *II = dyn_cast<InvokeInst>(TheCall)) {
2060 BasicBlock *UnwindDest = II->getUnwindDest();
2062 if (isa<LandingPadInst>(FirstNonPHI)) {
2073 if (CallSiteEHPad) {
2088 if (CalledFn && CalledFn->isIntrinsic() && CS.
doesNotThrow())
2116 if (
auto *CleanupRet = dyn_cast<CleanupReturnInst>(BB->getTerminator()))
2117 if (CleanupRet->unwindsToCaller() && EHPadForCallUnwindsLocally)
2124 if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(I)) {
2125 if (isa<ConstantTokenNone>(CatchSwitch->getParentPad()))
2126 CatchSwitch->setParentPad(CallSiteEHPad);
2128 auto *FPI = cast<FuncletPadInst>(
I);
2129 if (isa<ConstantTokenNone>(FPI->getParentPad()))
2130 FPI->setParentPad(CallSiteEHPad);
2135 if (InlinedDeoptimizeCalls) {
2145 Returns.
erase(NewEnd, Returns.
end());
2149 Caller->
getParent(), Intrinsic::experimental_deoptimize,
2176 "Expected at least the deopt operand bundle");
2180 Builder.CreateCall(NewDeoptIntrinsic, CallArgs, OpBundles);
2183 Builder.CreateRetVoid();
2185 Builder.CreateRet(NewDeoptCall);
2197 if (InlinedMustTailCalls) {
2200 bool NeedBitCast = !TheCall->
use_empty() && TheCall->
getType() != NewRetTy;
2207 if (!ReturnedMustTail) {
2216 auto *OldCast = dyn_cast_or_null<BitCastInst>(RI->getReturnValue());
2219 OldCast->eraseFromParent();
2247 if (Returns.
size() == 1 && std::distance(FirstNewBlock, Caller->
end()) == 1) {
2250 FirstNewBlock->getInstList(),
2251 FirstNewBlock->begin(), FirstNewBlock->end());
2257 if (
InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
2275 Returns[0]->eraseFromParent();
2288 BranchInst *CreatedBranchToNormalDest =
nullptr;
2289 if (
InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
2299 CalledFunc->
getName() +
".exit");
2306 CalledFunc->
getName() +
".exit");
2320 "splitBasicBlock broken!");
2335 if (Returns.
size() > 1) {
2340 &AfterCallBB->
front());
2349 for (
unsigned i = 0,
e = Returns.
size(); i !=
e; ++i) {
2352 "Ret value not consistent in function!");
2359 for (
unsigned i = 0,
e = Returns.
size(); i !=
e; ++i) {
2370 if (CreatedBranchToNormalDest)
2372 }
else if (!Returns.
empty()) {
2376 if (TheCall == Returns[0]->getReturnValue())
2383 BasicBlock *ReturnBB = Returns[0]->getParent();
2391 if (CreatedBranchToNormalDest)
2395 Returns[0]->eraseFromParent();
2413 assert(cast<BranchInst>(Br)->isUnconditional() &&
"splitBasicBlock broken!");
2414 BasicBlock *CalleeEntry = cast<BranchInst>(Br)->getSuccessor(0);
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
static DebugLoc inlineDebugLoc(DebugLoc OrigDL, DILocation *InlinedAt, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode *> &IANodes)
Returns a DebugLoc for a new DILocation which is a clone of OrigDL inlined at InlinedAt.
Return a value (possibly void), from a function.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
A parsed version of the target data layout string in and methods for querying it. ...
reference emplace_back(ArgTypes &&... Args)
DILocation * get() const
Get the underlying DILocation.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
static cl::opt< bool > EnableNoAliasConversion("enable-noalias-to-md-conversion", cl::init(true), cl::Hidden, cl::desc("Convert noalias attributes to metadata during inlining."))
unsigned getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign, const DataLayout &DL, const Instruction *CxtI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
Try to ensure that the alignment of V is at least PrefAlign bytes.
static void updateCallProfile(Function *Callee, const ValueToValueMapTy &VMap, const ProfileCount &CalleeEntryCount, const Instruction *TheCall, ProfileSummaryInfo *PSI, BlockFrequencyInfo *CallerBFI)
Update the branch metadata for cloned call instructions.
This class represents an incoming formal argument to a Function.
iterator erase(iterator where)
This class represents lattice values for constants.
CallGraph * CG
If non-null, InlineFunction will update the callgraph to reflect the changes it makes.
A Module instance is used to store all the information related to an LLVM module. ...
void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
An instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
static DebugLoc appendInlinedAt(DebugLoc DL, DILocation *InlinedAt, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode *> &Cache, bool ReplaceLast=false)
Rebuild the entire inlined-at chain for this instruction so that the top of the chain now is inlined-...
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
std::function< AssumptionCache &(Function &)> * GetAssumptionCache
void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Notify the BasicBlock that the predecessor Pred is no longer able to reach it.
void push_back(const T &Elt)
void recalculate(ParentType &Func)
recalculate - compute a dominator tree for the given function
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Analysis providing profile information.
const CallInst * getTerminatingMustTailCall() const
Returns the call instruction marked 'musttail' prior to the terminating return instruction of this ba...
This class represents a function call, abstracting a target machine's calling convention.
void setGC(std::string Str)
A cache of @llvm.assume calls within a function.
bool isSwiftError() const
Return true if this alloca is used as a swifterror argument to a call.
uint64_t getFrequency() const
Returns the frequency as a fixpoint number scaled by the entry frequency.
LLVMContext & getContext() const
All values hold a context through their type.
static void AddAlignmentAssumptions(CallSite CS, InlineFunctionInfo &IFI)
If the inlined function has non-byval align arguments, then add .assume-based alignment assumptions t...
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
const MDOperand & getOperand(unsigned I) const
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
An instruction for reading from memory.
FunTy * getCalledFunction() const
Return the function being called if this is a direct call, otherwise return null (if it's an indirect...
Optional< OperandBundleUse > getOperandBundle(StringRef Name) const
static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap, const DataLayout &DL, AAResults *CalleeAAR)
If the inlined function has noalias arguments, then add new alias scopes for each noalias argument...
static IntegerType * getInt64Ty(LLVMContext &C)
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
void reserve(size_type N)
bool isMustTailCall() const
This class captures the data input to the InlineFunction call, and records the auxiliary results prod...
iterator end()
Get an iterator to the end of the SetVector.
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock *> IndirectDests, ArrayRef< Value *> Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
A node in the call graph for a module.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
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...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
iterator begin()
Instruction iterator methods.
Function::ProfileCount ProfileCount
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
unsigned getAllocaAddrSpace() const
const CallInst * getTerminatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize prior to the terminating return in...
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
void setEntryCount(ProfileCount Count, const DenseSet< GlobalValue::GUID > *Imports=nullptr)
Set the entry count for this function.
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...
PointerType * getType() const
Overload to return most specific pointer type.
TailCallKind getTailCallKind() const
A Use represents the edge between a Value definition and its users.
ValTy * getCalledValue() const
Return the pointer to function that is being called.
uint32_t getTagID() const
Return the tag of this operand bundle as an integer.
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.
ReturnInst * CreateRet(Value *V)
Create a 'ret <val>' instruction.
AttributeSet getRetAttributes() const
The attributes for the ret value are returned.
static void CloneAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap)
When inlining a function that contains noalias scope metadata, this metadata needs to be cloned so th...
The only memory references in this function (if it has any) are non-volatile loads from objects point...
void setBlockFreqAndScale(const BasicBlock *ReferenceBB, uint64_t Freq, SmallPtrSetImpl< BasicBlock *> &BlocksToScale)
Set the frequency of ReferenceBB to Freq and scale the frequencies of the blocks in BlocksToScale suc...
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
std::vector< CallRecord > CalledFunctionsVector
bool isScopedEHPersonality(EHPersonality Pers)
Returns true if this personality uses scope-style EH IR instructions: catchswitch, catchpad/ret, and cleanuppad/ret.
FunctionModRefBehavior getModRefBehavior(const CallBase *Call)
Return the behavior of the given call site.
void addHandler(BasicBlock *Dest)
Add an entry to the switch instruction...
InstrTy * getInstruction() const
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
bool doesNotThrow() const
Determine if the call cannot unwind.
static void UpdateCallGraphAfterInlining(CallSite CS, Function::iterator FirstNewBlock, ValueToValueMapTy &VMap, InlineFunctionInfo &IFI)
Once we have cloned code over from a callee into the caller, update the specified callgraph to reflec...
void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl< ReturnInst *> &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr, Instruction *TheCall=nullptr)
This works exactly like CloneFunctionInto, except that it does some simple constant prop and DCE on t...
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
static void UpdatePHINodes(BasicBlock *OrigBB, BasicBlock *NewBB, ArrayRef< BasicBlock *> Preds, BranchInst *BI, bool HasLoopExit)
Update the PHI nodes in OrigBB to include the values coming from NewBB.
Type * getType() const
All values are typed, get the type of this value.
std::vector< WeakTrackingVH > OperandBundleCallSites
All cloned call sites that have operand bundles attached are appended to this vector.
bool insert(const value_type &X)
Insert a new element into the SetVector.
LandingPadInst * getLandingPadInst() const
Get the landingpad instruction from the landing pad block (the unwind destination).
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
Value * getCalledOperand() const
LLVMContext & getContext() const
FunctionModRefBehavior
Summary of how a function affects memory in the program.
AttributeSet getParamAttributes(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
iterator find(const KeyT &Val)
iterator begin()
Get an iterator to the beginning of the SetVector.
BlockFrequencyInfo * CalleeBFI
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
iterator_range< User::op_iterator > arg_operands()
const std::string & getGC() const
An instruction for storing to memory.
bool hasPersonalityFn() const
Check whether this function has a personality function.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
bool PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures, bool StoreCaptures, const Instruction *I, const DominatorTree *DT, bool IncludeI=false, OrderedBasicBlock *OBB=nullptr, unsigned MaxUsesToExplore=DefaultMaxUsesToExplore)
PointerMayBeCapturedBefore - Return true if this pointer value may be captured by the enclosing funct...
bool doesNotThrow() const
Determine if the call cannot unwind.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
void takeName(Value *V)
Transfer the name from V to this value.
InlineResult is basically true or false.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Value * getOperand(unsigned i) const
Class to represent pointers.
Optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Return an operand bundle by name, if present.
static BasicBlock * HandleCallsInBlockInlinedThroughInvoke(BasicBlock *BB, BasicBlock *UnwindEdge, 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 bool isUsedByLifetimeMarker(Value *V)
iterator find(const_arg_type_t< KeyT > Val)
static cl::opt< bool > PreserveAlignmentAssumptions("preserve-alignment-assumptions-during-inlining", cl::init(true), cl::Hidden, cl::desc("Convert align attributes to assumptions during inlining."))
bool isVoidTy() const
Return true if this is 'void'.
const BasicBlock & getEntryBlock() const
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata *> MDs)
Return a temporary node.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
void setCallingConv(CallingConv::ID CC)
SmallVector< CallSite, 8 > InlinedCallSites
All of the new call sites inlined into the caller.
initializer< Ty > init(const Ty &Val)
Type * getReturnType() const
Returns the type of the ret val.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
void GetUnderlyingObjects(const Value *V, SmallVectorImpl< const Value *> &Objects, const DataLayout &DL, LoopInfo *LI=nullptr, unsigned MaxLookup=6)
This method is similar to GetUnderlyingObject except that it can look through phi and select instruct...
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
uint64_t getCount() const
unsigned getNumArgOperands() const
Value * getCalledValue() const
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
DISubprogram * getSubprogram() const
Get the attached subprogram.
Conditional or Unconditional Branch instruction.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
Resume the propagation of an exception.
static MDNode * inlineLoopID(const MDNode *OrigLoopId, DILocation *InlinedAt, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode *> &IANodes)
Returns the LoopID for a loop which has has been cloned from another function for inlining with the n...
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata *> MDs)
Value * getIncomingValueForBlock(const BasicBlock *BB) const
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const Instruction & front() const
AttributeList getAttributes() const
Get the parameter attributes of the call.
FunctionType * getFunctionType() const
ValTy * getArgument(unsigned ArgNo) const
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
ProfileCount getEntryCount(bool AllowSynthetic=false) const
Get the entry count for this function.
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
void splice(iterator where, iplist_impl &L2)
static Value * getUnwindDestTokenHelper(Instruction *EHPad, UnwindDestMemoTy &MemoMap)
Helper for getUnwindDestToken that does the descendant-ward part of the search.
void removeCallEdgeFor(CallBase &Call)
Removes the edge in the node for the specified call site.
static bool hasLifetimeMarkers(AllocaInst *AI)
void setCallingConv(CallingConv::ID CC)
The only memory references in this function (if it has any) are non-volatile loads and stores from ob...
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Interval::pred_iterator pred_end(Interval *I)
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
self_iterator getIterator()
void setTailCallKind(TailCallKind TCK)
const Function * getFunction() const
Return the function this instruction belongs to.
auto remove_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly...
MDNode * getScope() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
InlineResult InlineFunction(CallBase *CB, InlineFunctionInfo &IFI, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true)
This function inlines the called function into the basic block of the caller.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
MDNode * uniteAccessGroups(MDNode *AccGroups1, MDNode *AccGroups2)
Compute the union of two access-group lists.
const Constant * stripPointerCasts() const
static constexpr const Align None()
Returns a default constructed Align which corresponds to no alignment.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
iterator erase(const_iterator CI)
Class to represent profile counts.
const Value * getArraySize() const
Get the number of elements allocated.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Optional< uint64_t > getProfileCount(const Instruction *CallInst, BlockFrequencyInfo *BFI, bool AllowSynthetic=false)
Returns the profile count for CallInst.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
bool isIdentifiedFunctionLocal(const Value *V)
Return true if V is umabigously identified at the function-level.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
static void HandleByValArgumentInit(Value *Dst, Value *Src, Module *M, BasicBlock *InsertBlock, InlineFunctionInfo &IFI)
const InstListType & getInstList() const
Return the underlying instruction list container.
A SetVector that performs no allocations if smaller than a certain size.
Iterator for intrusive lists based on ilist_node.
This is the shared class of boolean and integer constants.
Align max(MaybeAlign Lhs, Align Rhs)
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Module.h This file contains the declarations for the Module class.
unsigned getNumOperandBundles() const
void setBlockFreq(const BasicBlock *BB, uint64_t Freq)
LLVM_NODISCARD T pop_back_val()
static Value * getParentPad(Value *EHPad)
Helper for getUnwindDestToken/getUnwindDestTokenHelper.
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
static cl::opt< bool > NoAliases("riscv-no-aliases", cl::desc("Disable the emission of assembler pseudo instructions"), cl::init(false), cl::Hidden)
static Value * getUnwindDestToken(Instruction *EHPad, UnwindDestMemoTy &MemoMap)
Given an EH pad, find where it unwinds.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
std::string utostr(uint64_t X, bool isNeg=false)
AttributeList getAttributes() const
Return the parameter attributes for this call.
BlockFrequency getBlockFreq(const BasicBlock *BB) const
getblockFreq - Return block frequency.
void setOperand(unsigned i, Value *Val)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
amdgpu Simplify well known AMD library false FunctionCallee Callee
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
iterator_range< user_iterator > users()
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
bool ContainsCalls
This is set to true if the cloned code contains a normal call instruction.
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
SmallVector< AllocaInst *, 4 > StaticAllocas
InlineFunction fills this in with all static allocas that get copied into the caller.
The basic data container for the call graph of a Module of IR.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
void registerAssumption(CallInst *CI)
Add an @llvm.assume intrinsic to this function's cache.
static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
Return the first found DebugLoc that has a DILocation, given a range of instructions.
LLVM_NODISCARD bool empty() const
SmallVector< WeakTrackingVH, 8 > InlinedCalls
InlineFunction fills this in with callsites that were inlined from the callee.
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value *> Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
CallingConv::ID getCallingConv() const
StringRef getName() const
Return a constant reference to the value's name.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
const Function * getParent() const
Return the enclosing method, or null if none.
static MDNode * concatenate(MDNode *A, MDNode *B)
Methods for metadata merging.
static void PropagateParallelLoopAccessMetadata(CallSite CS, ValueToValueMapTy &VMap)
When inlining a call site that has !llvm.mem.parallel_loop_access or llvm.access.group metadata...
SymbolTableList< BasicBlock >::iterator eraseFromParent()
Unlink 'this' from the containing function and delete it.
bool empty() const
Determine if the SetVector is empty or not.
static Value * HandleByValArgument(Value *Arg, Instruction *TheCall, const Function *CalledFunc, InlineFunctionInfo &IFI, unsigned ByValAlignment)
When inlining a call site that has a byval argument, we have to make the implicit memcpy explicit by ...
This struct can be used to capture information about code being cloned, while it is being cloned...
void setAttributes(AttributeList A)
Set the parameter attributes for this call.
unsigned getKnownAlignment(Value *V, const DataLayout &DL, const Instruction *CxtI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
Try to infer an alignment for the specified pointer.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
const BasicBlockListType & getBasicBlockList() const
Get the underlying elements of the Function...
static ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="")
Split the basic block into two basic blocks at the specified instruction.
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
std::vector< CallRecord >::iterator iterator
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
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...
bool isCallBr() const
Return true if a CallBrInst is enclosed.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
static bool allocaWouldBeStaticInEntry(const AllocaInst *AI)
Return the result of AI->isStaticAlloca() if AI were moved to the entry block.
BlockFrequencyInfo * CallerBFI
bool isCall() const
Return true if a CallInst is enclosed.
size_type count(const KeyT &Val) const
Return 1 if the specified key is in the map, 0 otherwise.
bool replaceDbgDeclareForAlloca(AllocaInst *AI, Value *NewAllocaAddress, DIBuilder &Builder, uint8_t DIExprFlags, int Offset)
Replaces llvm.dbg.declare instruction when the alloca it describes is replaced with a new value...
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool ContainsDynamicAllocas
This is set to true if the cloned code contains a 'dynamic' alloca.
const BasicBlock & front() const
bool isAsynchronousEHPersonality(EHPersonality Pers)
Returns true if this personality function catches asynchronous exceptions.
BasicBlock * getUnwindDest() const
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
A vector that has set insertion semantics.
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB=nullptr, Instruction *InsertBefore=nullptr)
AttributeSet getFnAttributes() const
The function attributes are returned.
BasicBlock * changeToInvokeAndSplitBasicBlock(CallInst *CI, BasicBlock *UnwindEdge)
Convert the CallInst to InvokeInst with the specified unwind edge basic block.
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
OperandBundleUse getOperandBundleAt(unsigned Index) const
void setPersonalityFn(Constant *Fn)
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...
unsigned getNumOperands() const
Return number of MDNode operands.
bool isEmpty() const
Return true if there are no attributes.
Value * SimplifyInstruction(Instruction *I, const SimplifyQuery &Q, OptimizationRemarkEmitter *ORE=nullptr)
See if we can compute a simplified version of this instruction.
unsigned changeToUnreachable(Instruction *I, bool UseLLVMTrap, 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...
Type * getElementType() const
ValTy * getArgOperand(unsigned i) const
static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute >> Attrs)
Create an AttributeList with the specified parameters in it.
iterator_range< arg_iterator > args()
bool hasOperandBundles() const
void addCalledFunction(CallBase *Call, CallGraphNode *M)
Adds a function to the list of functions called by this one.
A wrapper class for inspecting calls to intrinsic functions.
const BasicBlock * getParent() const
an instruction to allocate memory on the stack
bool mayReadOrWriteMemory() const
Return true if this instruction may read or write memory.
FunTy * getCaller() const
Return the caller function for this call site.