;
24using namespaceCodeGen;
65 caseAggregateLiteral:
66 caseAggregateAddress:
69 caseComplexAddress: {
76llvm_unreachable(
"bad saved r-value kind");
80char*EHScopeStack::allocate(
size_tSize) {
83 unsignedCapacity = 1024;
84 while(Capacity < Size) Capacity *= 2;
85StartOfBuffer =
new char[Capacity];
86StartOfData = EndOfBuffer = StartOfBuffer + Capacity;
87}
else if(
static_cast<size_t>(StartOfData - StartOfBuffer) < Size) {
88 unsignedCurrentCapacity = EndOfBuffer - StartOfBuffer;
89 unsignedUsedCapacity = CurrentCapacity - (StartOfData - StartOfBuffer);
91 unsignedNewCapacity = CurrentCapacity;
94}
while(NewCapacity < UsedCapacity + Size);
96 char*NewStartOfBuffer =
new char[NewCapacity];
97 char*NewEndOfBuffer = NewStartOfBuffer + NewCapacity;
98 char*NewStartOfData = NewEndOfBuffer - UsedCapacity;
99 memcpy(NewStartOfData, StartOfData, UsedCapacity);
100 delete[] StartOfBuffer;
101StartOfBuffer = NewStartOfBuffer;
102EndOfBuffer = NewEndOfBuffer;
103StartOfData = NewStartOfData;
106assert(StartOfBuffer + Size <= StartOfData);
107StartOfData -=
Size;
111voidEHScopeStack::deallocate(
size_tSize) {
123 if(!cleanup->isLifetimeMarker() && !cleanup->isFakeUse())
133 if(
auto*cleanup = dyn_cast<EHCleanupScope>(&*
find(si)))
134 if(cleanup->isLifetimeMarker()) {
135si = cleanup->getEnclosingEHScope();
149 if(cleanup.isActive())
returnsi;
150si = cleanup.getEnclosingNormalCleanup();
156void*EHScopeStack::pushCleanup(
CleanupKindKind,
size_tSize) {
161 boolIsFakeUse = Kind &
FakeUse;
169IsEHCleanup =
false;
176InnermostNormalCleanup,
182 if(IsLifetimeMarker)
183 Scope->setLifetimeMarker();
185 Scope->setFakeUse();
193 if(CGF->
getLangOpts().EHAsynch && IsEHCleanup && !IsLifetimeMarker &&
197 return Scope->getCleanupBuffer();
201assert(!
empty() &&
"popping exception stack when not empty");
203assert(isa<EHCleanupScope>(*
begin()));
205InnermostNormalCleanup =
Cleanup.getEnclosingNormalCleanup();
206InnermostEHScope =
Cleanup.getEnclosingEHScope();
207deallocate(
Cleanup.getAllocatedSize());
213 if(!BranchFixups.empty()) {
217BranchFixups.clear();
234assert(!
empty() &&
"popping exception stack when not empty");
245 new(buffer)
EHCatchScope(numHandlers, InnermostEHScope);
267 unsignedMinSize = cast<EHCleanupScope>(*it).getFixupDepth();
268assert(BranchFixups.size() >= MinSize &&
"fixup stack out of order");
270 while(BranchFixups.size() > MinSize &&
271BranchFixups.back().Destination ==
nullptr)
272BranchFixups.pop_back();
293assert(!cleanup.hasActiveFlag() &&
"cleanup already has active flag?");
294cleanup.setActiveFlag(ActiveFlag);
296 if(cleanup.isNormalCleanup()) cleanup.setTestFlagInNormalCleanup();
297 if(cleanup.isEHCleanup()) cleanup.setTestFlagInEHCleanup();
300voidEHScopeStack::Cleanup::anchor() {}
303llvm::BasicBlock::iterator beforeInst,
305 autostore =
newllvm::StoreInst(value, addr.
emitRawPointer(CGF), beforeInst);
309staticllvm::LoadInst *
311llvm::BasicBlock::iterator beforeInst,
328llvm::SwitchInst *
Switch,
329llvm::BasicBlock *CleanupEntry) {
353 if(!CasesAdded.insert(Fixup.
Destination).second)
366llvm::BasicBlock *
Block) {
369llvm::Instruction *Term =
Block->getTerminator();
370assert(Term &&
"can't transition block without terminator");
372 if(llvm::BranchInst *Br = dyn_cast<llvm::BranchInst>(Term)) {
373assert(Br->isUnconditional());
375 "cleanup.dest", Term->getIterator(), CGF);
376llvm::SwitchInst *
Switch=
377llvm::SwitchInst::Create(Load, Br->getSuccessor(0), 4,
Block);
378Br->eraseFromParent();
381 returncast<llvm::SwitchInst>(Term);
386assert(
Block&&
"resolving a null target block");
387 if(!EHStack.getNumBranchFixups())
return;
389assert(EHStack.hasNormalCleanups() &&
390 "branch fixups exist with no normal cleanups on stack");
393 boolResolvedAny =
false;
395 for(
unsignedI = 0,
E= EHStack.getNumBranchFixups(); I !=
E; ++I) {
410 if(!ModifiedOptimisticBlocks.insert(BranchBB).second)
420EHStack.popNullFixups();
426std::initializer_list<llvm::Value **> ValuesToReload) {
429 boolHadBranches =
false;
430 while(EHStack.stable_begin() != Old) {
432HadBranches |=
Scope.hasBranches();
437 boolFallThroughIsBranchThrough =
440PopCleanupBlock(FallThroughIsBranchThrough);
451 for(llvm::Value **ReloadedValue : ValuesToReload) {
452 auto*Inst = dyn_cast_or_null<llvm::Instruction>(*ReloadedValue);
458 auto*AI = dyn_cast<llvm::AllocaInst>(Inst);
459 if(AI && AI->isStaticAlloca())
463CreateDefaultAlignTempAlloca(Inst->getType(),
"tmp.exprcleanup");
466llvm::BasicBlock::iterator InsertBefore;
467 if(
auto*Invoke = dyn_cast<llvm::InvokeInst>(Inst))
468InsertBefore = Invoke->getNormalDest()->getFirstInsertionPt();
470InsertBefore = std::next(Inst->getIterator());
474*ReloadedValue = Builder.CreateLoad(Tmp);
482std::initializer_list<llvm::Value **> ValuesToReload) {
483PopCleanupBlocks(Old, ValuesToReload);
486 for(
size_tI = OldLifetimeExtendedSize,
487 E= LifetimeExtendedCleanupStack.size(); I !=
E;
) {
489assert((I %
alignof(LifetimeExtendedCleanupHeader) == 0) &&
490 "misaligned cleanup stack entry");
492LifetimeExtendedCleanupHeader &Header =
493 reinterpret_cast<LifetimeExtendedCleanupHeader&
>(
494LifetimeExtendedCleanupStack[I]);
495I +=
sizeof(Header);
497EHStack.pushCopyOfCleanup(Header.getKind(),
498&LifetimeExtendedCleanupStack[I],
500I += Header.getSize();
502 if(Header.isConditional()) {
504 reinterpret_cast<RawAddress&
>(LifetimeExtendedCleanupStack[I]);
505initFullExprCleanupWithFlag(ActiveFlag);
506I +=
sizeof(ActiveFlag);
509LifetimeExtendedCleanupStack.resize(OldLifetimeExtendedSize);
514assert(
Scope.isNormalCleanup());
515llvm::BasicBlock *Entry =
Scope.getNormalBlock();
518 Scope.setNormalBlock(Entry);
529llvm::BasicBlock *Entry) {
530llvm::BasicBlock *Pred = Entry->getSinglePredecessor();
531 if(!Pred)
returnEntry;
533llvm::BranchInst *Br = dyn_cast<llvm::BranchInst>(Pred->getTerminator());
534 if(!Br || Br->isConditional())
returnEntry;
535assert(Br->getSuccessor(0) == Entry);
540 boolWasInsertBlock = CGF.
Builder.GetInsertBlock() == Entry;
541assert(!WasInsertBlock || CGF.
Builder.GetInsertPoint() == Entry->end());
544Br->eraseFromParent();
548Entry->replaceAllUsesWith(Pred);
551Pred->splice(Pred->end(), Entry);
554Entry->eraseFromParent();
557CGF.
Builder.SetInsertPoint(Pred);
568llvm::BasicBlock *ContBB =
nullptr;
572llvm::Value *IsActive
574CGF.
Builder.CreateCondBr(IsActive, CleanupBB, ContBB);
579Fn->Emit(CGF, flags);
580assert(CGF.
HaveInsertPoint() &&
"cleanup ended with no insertion point?");
588llvm::BasicBlock *From,
589llvm::BasicBlock *To) {
592llvm::Instruction *Term = Exit->getTerminator();
594 if(llvm::BranchInst *Br = dyn_cast<llvm::BranchInst>(Term)) {
595assert(Br->isUnconditional() && Br->getSuccessor(0) == From);
596Br->setSuccessor(0, To);
598llvm::SwitchInst *
Switch= cast<llvm::SwitchInst>(Term);
599 for(
unsignedI = 0,
E=
Switch->getNumSuccessors(); I !=
E; ++I)
600 if(
Switch->getSuccessor(I) == From)
601 Switch->setSuccessor(I, To);
618 for(llvm::BasicBlock::use_iterator
619i = entry->use_begin(), e = entry->use_end(); i != e; ) {
623use.set(unreachableBB);
626llvm::SwitchInst *si = cast<llvm::SwitchInst>(use.getUser());
627 if(si->getNumCases() == 1 && si->getDefaultDest() == unreachableBB) {
629llvm::BranchInst::Create(si->case_begin()->getCaseSuccessor(),
633llvm::LoadInst *condition = cast<llvm::LoadInst>(si->getCondition());
636si->eraseFromParent();
640assert(condition->use_empty());
641condition->eraseFromParent();
645assert(entry->use_empty());
654assert(!EHStack.empty() &&
"cleanup stack is empty!");
655assert(isa<EHCleanupScope>(*EHStack.begin()) &&
"top not a cleanup!");
657assert(
Scope.getFixupDepth() <= EHStack.getNumBranchFixups());
661CGBuilderTy::InsertPoint NormalDeactivateOrigIP;
663NormalDeactivateOrigIP = Builder.saveAndClearIP();
666 boolIsActive =
Scope.isActive();
668 Scope.shouldTestFlagInNormalCleanup() ?
Scope.getActiveFlag()
671 Scope.shouldTestFlagInEHCleanup() ?
Scope.getActiveFlag()
676llvm::BasicBlock *EHEntry =
Scope.getCachedEHDispatchBlock();
677assert(
Scope.hasEHBranches() == (EHEntry !=
nullptr));
678 boolRequiresEHCleanup = (EHEntry !=
nullptr);
684 unsignedFixupDepth =
Scope.getFixupDepth();
685 boolHasFixups = EHStack.getNumBranchFixups() != FixupDepth;
688 boolHasExistingBranches =
Scope.hasBranches();
691llvm::BasicBlock *FallthroughSource = Builder.GetInsertBlock();
692 boolHasFallthrough =
693FallthroughSource !=
nullptr&& (IsActive || HasExistingBranches);
699 boolHasPrebranchedFallthrough =
700(FallthroughSource && FallthroughSource->getTerminator());
705assert(!
Scope.isNormalCleanup() || !HasPrebranchedFallthrough ||
706(
Scope.getNormalBlock() &&
707FallthroughSource->getTerminator()->getSuccessor(0)
708==
Scope.getNormalBlock()));
710 boolRequiresNormalCleanup =
false;
711 if(
Scope.isNormalCleanup() &&
712(HasFixups || HasExistingBranches || HasFallthrough)) {
713RequiresNormalCleanup =
true;
718 if(
Scope.isNormalCleanup() && HasPrebranchedFallthrough &&
719!RequiresNormalCleanup) {
723llvm::BasicBlock *prebranchDest;
728 if(FallthroughIsBranchThrough) {
729 EHScope&enclosing = *EHStack.find(
Scope.getEnclosingNormalCleanup());
737prebranchDest = createBasicBlock(
"forwarded-prebranch");
738EmitBlock(prebranchDest);
741llvm::BasicBlock *normalEntry =
Scope.getNormalBlock();
742assert(normalEntry && !normalEntry->use_empty());
745normalEntry, prebranchDest);
749 if(!RequiresNormalCleanup && !RequiresEHCleanup) {
751EHStack.popCleanup();
752assert(EHStack.getNumBranchFixups() == 0 ||
753EHStack.hasNormalCleanups());
754 if(NormalDeactivateOrigIP.isSet())
755Builder.restoreIP(NormalDeactivateOrigIP);
764 auto*CleanupSource =
reinterpret_cast<char*
>(
Scope.getCleanupBuffer());
766CleanupBufferStack[8 *
sizeof(
void*)];
767std::unique_ptr<char[]> CleanupBufferHeap;
768 size_tCleanupSize =
Scope.getCleanupSize();
771 if(CleanupSize <=
sizeof(CleanupBufferStack)) {
772 memcpy(CleanupBufferStack, CleanupSource, CleanupSize);
775CleanupBufferHeap.reset(
new char[CleanupSize]);
776 memcpy(CleanupBufferHeap.get(), CleanupSource, CleanupSize);
781 if(
Scope.isNormalCleanup())
783 if(
Scope.isEHCleanup())
787 boolIsEHa = getLangOpts().EHAsynch && !
Scope.isLifetimeMarker();
789 if(!RequiresNormalCleanup) {
792 if(IsEHa && getInvokeDest()) {
796 if(NormalDeactivateOrigIP.isSet())
797Builder.restoreIP(NormalDeactivateOrigIP);
799EmitSehCppScopeEnd();
800 if(NormalDeactivateOrigIP.isSet())
801NormalDeactivateOrigIP = Builder.saveAndClearIP();
804 Scope.MarkEmitted();
805EHStack.popCleanup();
809 if(HasFallthrough && !HasPrebranchedFallthrough && !HasFixups &&
810!HasExistingBranches) {
813 if(IsEHa && getInvokeDest()) {
815EmitSehCppScopeEnd();
817EmitSehTryScopeEnd();
821 Scope.MarkEmitted();
822EHStack.popCleanup();
824 EmitCleanup(*
this, Fn, cleanupFlags, NormalActiveFlag);
834CGBuilderTy::InsertPoint savedInactiveFallthroughIP;
838 if(HasFallthrough) {
839 if(!HasPrebranchedFallthrough)
840Builder.CreateStore(Builder.getInt32(0), getNormalCleanupDestSlot());
844}
else if(FallthroughSource) {
845assert(!IsActive &&
"source without fallthrough for active cleanup");
846savedInactiveFallthroughIP = Builder.saveAndClearIP();
852EmitBlock(NormalEntry);
855 if(IsEHa && getInvokeDest()) {
857EmitSehCppScopeEnd();
859EmitSehTryScopeEnd();
865 boolHasEnclosingCleanups =
866(
Scope.getEnclosingNormalCleanup() != EHStack.stable_end());
873llvm::BasicBlock *BranchThroughDest =
nullptr;
874 if(
Scope.hasBranchThroughs() ||
875(FallthroughSource && FallthroughIsBranchThrough) ||
876(HasFixups && HasEnclosingCleanups)) {
877assert(HasEnclosingCleanups);
878 EHScope&S = *EHStack.find(
Scope.getEnclosingNormalCleanup());
882llvm::BasicBlock *FallthroughDest =
nullptr;
892 if(!
Scope.hasBranchThroughs() && !HasFixups && !HasFallthrough &&
893!currentFunctionUsesSEHTry() &&
Scope.getNumBranchAfters() == 1) {
894assert(!BranchThroughDest || !IsActive);
897llvm::Instruction *NormalCleanupDestSlot =
898cast<llvm::Instruction>(getNormalCleanupDestSlot().getPointer());
899 if(NormalCleanupDestSlot->hasOneUse()) {
900NormalCleanupDestSlot->user_back()->eraseFromParent();
901NormalCleanupDestSlot->eraseFromParent();
905llvm::BasicBlock *BranchAfter =
Scope.getBranchAfterBlock(0);
906InstsToAppend.push_back(llvm::BranchInst::Create(BranchAfter));
913}
else if(
Scope.getNumBranchAfters() ||
914(HasFallthrough && !FallthroughIsBranchThrough) ||
915(HasFixups && !HasEnclosingCleanups)) {
918(BranchThroughDest ? BranchThroughDest : getUnreachableBlock());
921 const unsignedSwitchCapacity = 10;
927 "cleanup.dest", *
this);
928llvm::SwitchInst *
Switch=
929llvm::SwitchInst::Create(Load,
Default, SwitchCapacity);
931InstsToAppend.push_back(Load);
932InstsToAppend.push_back(
Switch);
935 if(FallthroughSource && !FallthroughIsBranchThrough) {
936FallthroughDest = createBasicBlock(
"cleanup.cont");
938 Switch->addCase(Builder.getInt32(0), FallthroughDest);
941 for(
unsignedI = 0,
E=
Scope.getNumBranchAfters(); I !=
E; ++I) {
943 Scope.getBranchAfterBlock(I));
948 if(HasFixups && !HasEnclosingCleanups)
952assert(BranchThroughDest);
953InstsToAppend.push_back(llvm::BranchInst::Create(BranchThroughDest));
957 Scope.MarkEmitted();
958EHStack.popCleanup();
959assert(EHStack.hasNormalCleanups() == HasEnclosingCleanups);
961 EmitCleanup(*
this, Fn, cleanupFlags, NormalActiveFlag);
964llvm::BasicBlock *NormalExit = Builder.GetInsertBlock();
965 for(
unsignedI = 0,
E= InstsToAppend.size(); I !=
E; ++I)
966InstsToAppend[I]->insertInto(NormalExit, NormalExit->end());
969 for(
unsignedI = FixupDepth,
E= EHStack.getNumBranchFixups();
976getNormalCleanupDestSlot(),
987 if(!HasFallthrough && FallthroughSource) {
992Builder.restoreIP(savedInactiveFallthroughIP);
997}
else if(HasFallthrough && FallthroughDest) {
998assert(!FallthroughIsBranchThrough);
999EmitBlock(FallthroughDest);
1003}
else if(HasFallthrough) {
1008Builder.ClearInsertionPoint();
1015llvm::BasicBlock *NewNormalEntry =
1020 if(NewNormalEntry != NormalEntry && NormalEntry == NormalExit)
1021 for(
unsignedI = FixupDepth,
E= EHStack.getNumBranchFixups();
1023EHStack.getBranchFixup(I).OptimisticBranchBlock = NewNormalEntry;
1027 if(NormalDeactivateOrigIP.isSet())
1028Builder.restoreIP(NormalDeactivateOrigIP);
1029assert(EHStack.hasNormalCleanups() || EHStack.getNumBranchFixups() == 0);
1032 if(RequiresEHCleanup) {
1033CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();
1037llvm::BasicBlock *NextAction = getEHDispatchBlock(EHParent);
1042 boolPushedTerminate =
false;
1044llvm::CleanupPadInst *CPI =
nullptr;
1048llvm::Value *ParentPad = CurrentFuncletPad;
1050ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext());
1051CurrentFuncletPad = CPI = Builder.CreateCleanupPad(ParentPad);
1056EHStack.pushTerminate();
1057PushedTerminate =
true;
1058}
else if(IsEHa && getInvokeDest()) {
1059EmitSehCppScopeEnd();
1064 if(EHActiveFlag.
isValid() || IsActive) {
1066 EmitCleanup(*
this, Fn, cleanupFlags, EHActiveFlag);
1070Builder.CreateCleanupRet(CPI, NextAction);
1072Builder.CreateBr(NextAction);
1075 if(PushedTerminate)
1076EHStack.popTerminate();
1078Builder.restoreIP(SavedIP);
1088assert(Dest.getScopeDepth().encloses(EHStack.stable_begin())
1089&&
"stale jump destination");
1093EHStack.getInnermostActiveNormalCleanup();
1098 if(TopCleanup == EHStack.stable_end() ||
1099TopCleanup.
encloses(Dest.getScopeDepth()))
1113assert(Dest.getScopeDepth().encloses(EHStack.stable_begin())
1114&&
"stale jump destination");
1116 if(!HaveInsertPoint())
1120llvm::BranchInst *BI = Builder.CreateBr(Dest.getBlock());
1124TopCleanup = EHStack.getInnermostActiveNormalCleanup();
1129 if(TopCleanup == EHStack.stable_end() ||
1130TopCleanup.
encloses(Dest.getScopeDepth())) {
1131Builder.ClearInsertionPoint();
1137 if(!Dest.getScopeDepth().isValid()) {
1144Builder.ClearInsertionPoint();
1151llvm::ConstantInt *Index = Builder.getInt32(Dest.getDestIndex());
1158cast<EHCleanupScope>(*EHStack.find(TopCleanup));
1165 if(
E.strictlyEncloses(I)) {
1168assert(
Scope.isNormalCleanup());
1169I =
Scope.getEnclosingNormalCleanup();
1173 if(!
E.strictlyEncloses(I)) {
1174 Scope.addBranchAfter(Index, Dest.getBlock());
1181 if(!
Scope.addBranchThrough(Dest.getBlock()))
1186Builder.ClearInsertionPoint();
1198assert(cleanup.strictlyEncloses(i));
1223llvm::Instruction *dominatingIP) {
1229 boolisActivatedInConditional =
1232 boolneedFlag =
false;
1237 if(
Scope.isNormalCleanup()) {
1238 Scope.setTestFlagInNormalCleanup();
1243 if(
Scope.isEHCleanup() &&
1245 Scope.setTestFlagInEHCleanup();
1254 if(!var.isValid()) {
1255CodeGenFunction::AllocaTrackerRAII AllocaTracker(CGF);
1257 "cleanup.isactive");
1258 Scope.setActiveFlag(var);
1259 Scope.AddAuxAllocas(AllocaTracker.Take());
1261assert(dominatingIP &&
"no existing variable and no dominating IP!");
1281llvm::Instruction *dominatingIP) {
1282assert(
C!= EHStack.stable_end() &&
"activating bottom of stack?");
1284assert(!
Scope.isActive() &&
"double activation");
1288 Scope.setActive(
true);
1293llvm::Instruction *dominatingIP) {
1294assert(
C!= EHStack.stable_end() &&
"deactivating bottom of stack?");
1296assert(
Scope.isActive() &&
"double deactivation");
1300 if(
C== EHStack.stable_begin() &&
1301CurrentCleanupScopeDepth.strictlyEncloses(
C)) {
1302PopCleanupBlock(
false,
1310 Scope.setActive(
false);
1314 if(!NormalCleanupDest.isValid())
1316CreateDefaultAlignTempAlloca(Builder.getInt32Ty(),
"cleanup.dest.slot");
1317 returnNormalCleanupDest;
1331llvm::FunctionCallee &SehCppScope) {
1333assert(CGF.
Builder.GetInsertBlock() && InvokeDest);
1339CGF.
Builder.CreateInvoke(SehCppScope, Cont, InvokeDest, {}, BundleList);
1345assert(getLangOpts().EHAsynch);
1346llvm::FunctionType *FTy =
1347llvm::FunctionType::get(CGM.VoidTy,
false);
1348llvm::FunctionCallee SehCppScope =
1349CGM.CreateRuntimeFunction(FTy,
"llvm.seh.scope.begin");
1356assert(getLangOpts().EHAsynch);
1357llvm::FunctionType *FTy =
1358llvm::FunctionType::get(CGM.VoidTy,
false);
1359llvm::FunctionCallee SehCppScope =
1360CGM.CreateRuntimeFunction(FTy,
"llvm.seh.scope.end");
1366assert(getLangOpts().EHAsynch);
1367llvm::FunctionType *FTy =
1368llvm::FunctionType::get(CGM.VoidTy,
false);
1369llvm::FunctionCallee SehCppScope =
1370CGM.CreateRuntimeFunction(FTy,
"llvm.seh.try.begin");
1376assert(getLangOpts().EHAsynch);
1377llvm::FunctionType *FTy =
1378llvm::FunctionType::get(CGM.VoidTy,
false);
1379llvm::FunctionCallee SehCppScope =
1380CGM.CreateRuntimeFunction(FTy,
"llvm.seh.try.end");
static llvm::LoadInst * createLoadInstBefore(Address addr, const Twine &name, llvm::BasicBlock::iterator beforeInst, CodeGenFunction &CGF)
static void EmitSehScope(CodeGenFunction &CGF, llvm::FunctionCallee &SehCppScope)
static llvm::BasicBlock * CreateNormalEntry(CodeGenFunction &CGF, EHCleanupScope &Scope)
static void EmitCleanup(CodeGenFunction &CGF, EHScopeStack::Cleanup *Fn, EHScopeStack::Cleanup::Flags flags, Address ActiveFlag)
static void destroyOptimisticNormalEntry(CodeGenFunction &CGF, EHCleanupScope &scope)
We don't need a normal entry block for the given cleanup.
static void SetupCleanupBlockActivation(CodeGenFunction &CGF, EHScopeStack::stable_iterator C, ForActivation_t kind, llvm::Instruction *dominatingIP)
The given cleanup block is changing activation state.
static void ForwardPrebranchedFallthrough(llvm::BasicBlock *Exit, llvm::BasicBlock *From, llvm::BasicBlock *To)
static void createStoreInstBefore(llvm::Value *value, Address addr, llvm::BasicBlock::iterator beforeInst, CodeGenFunction &CGF)
static void ResolveAllBranchFixups(CodeGenFunction &CGF, llvm::SwitchInst *Switch, llvm::BasicBlock *CleanupEntry)
All the branch fixups on the EH stack have propagated out past the outermost normal cleanup; resolve ...
static bool IsUsedAsEHCleanup(EHScopeStack &EHStack, EHScopeStack::stable_iterator cleanup)
static llvm::BasicBlock * SimplifyCleanupEntry(CodeGenFunction &CGF, llvm::BasicBlock *Entry)
Attempts to reduce a cleanup's entry block to a fallthrough.
static llvm::SwitchInst * TransitionToCleanupSwitch(CodeGenFunction &CGF, llvm::BasicBlock *Block)
Transitions the terminator of the given exit-block of a cleanup to be a cleanup switch.
static Decl::Kind getKind(const Decl *D)
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Represents a C++ temporary.
llvm::Align getAsAlign() const
getAsAlign - Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit b...
static CharUnits One()
One - Construct a CharUnits quantity of one.
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
llvm::Value * emitRawPointer(CodeGenFunction &CGF) const
Return the pointer contained in this class after authenticating it and adding offset to it if necessa...
CharUnits getAlignment() const
llvm::Type * getElementType() const
Return the type of the values stored in this address.
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
void DeactivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
DeactivateCleanupBlock - Deactivates the given cleanup block.
void EmitSehCppScopeBegin()
RawAddress createCleanupActiveFlag()
RawAddress CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits align, const Twine &Name="tmp", llvm::Value *ArraySize=nullptr)
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
const LangOptions & getLangOpts() const
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
llvm::AllocaInst * CreateTempAlloca(llvm::Type *Ty, const Twine &Name="tmp", llvm::Value *ArraySize=nullptr)
CreateTempAlloca - This creates an alloca and inserts it into the entry block if ArraySize is nullptr...
SmallVector< llvm::OperandBundleDef, 1 > getBundlesForFunclet(llvm::Value *Callee)
RawAddress getNormalCleanupDestSlot()
void PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize, std::initializer_list< llvm::Value ** > ValuesToReload={})
Takes the old cleanup stack size and emits the cleanup blocks that have been added.
llvm::BasicBlock * getUnreachableBlock()
const TargetInfo & getTarget() const
bool isInConditionalBranch() const
isInConditionalBranch - Return true if we're currently emitting one branch or the other of a conditio...
void EmitSehCppScopeEnd()
void initFullExprCleanupWithFlag(RawAddress ActiveFlag)
llvm::BasicBlock * getInvokeDest()
void EmitSehTryScopeBegin()
void EmitSehTryScopeEnd()
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
void setBeforeOutermostConditional(llvm::Value *value, Address addr, CodeGenFunction &CGF)
void EmitCXXTemporary(const CXXTemporary *Temporary, QualType TempType, Address Ptr)
void EmitBranchThroughCleanup(JumpDest Dest)
EmitBranchThroughCleanup - Emit a branch from the current insert block through the normal cleanup han...
void PopCleanupBlock(bool FallThroughIsBranchThrough=false, bool ForDeactivation=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
void ActivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
ActivateCleanupBlock - Activates an initially-inactive cleanup.
RawAddress NormalCleanupDest
i32s containing the indexes of the cleanup destinations.
bool isObviouslyBranchWithoutCleanups(JumpDest Dest) const
isObviouslyBranchWithoutCleanups - Return true if a branch to the specified destination obviously has...
llvm::Instruction * CurrentFuncletPad
void ResolveBranchFixups(llvm::BasicBlock *Target)
A scope which attempts to handle some, possibly all, types of exceptions.
static size_t getSizeForNumHandlers(unsigned N)
A cleanup scope which generates the cleanup blocks lazily.
static size_t getSizeForCleanupSize(size_t Size)
Gets the size required for a lazy cleanup scope with the given cleanup-data requirements.
llvm::BasicBlock * getNormalBlock() const
An exceptions scope which filters exceptions thrown through it.
static size_t getSizeForNumFilters(unsigned numFilters)
unsigned getNumFilters() const
void setIsNormalCleanupKind()
void setIsEHCleanupKind()
Information for lazily generating a cleanup.
A non-stable pointer into the scope stack.
A saved depth on the scope stack.
bool encloses(stable_iterator I) const
Returns true if this scope encloses I.
bool strictlyEncloses(stable_iterator I) const
Returns true if this scope strictly encloses I: that is, if it encloses I and is not I.
A stack of scopes which respond to exceptions, including cleanups and catch blocks.
class EHFilterScope * pushFilter(unsigned NumFilters)
Push an exceptions filter on the stack.
BranchFixup & getBranchFixup(unsigned I)
stable_iterator getInnermostNormalCleanup() const
Returns the innermost normal cleanup on the stack, or stable_end() if there are no normal cleanups.
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
unsigned getNumBranchFixups() const
void popCleanup()
Pops a cleanup scope off the stack. This is private to CGCleanup.cpp.
stable_iterator getInnermostEHScope() const
bool requiresLandingPad() const
bool empty() const
Determines whether the exception-scopes stack is empty.
void popFilter()
Pops an exceptions filter off the stack.
iterator begin() const
Returns an iterator pointing to the innermost EH scope.
bool containsOnlyNoopCleanups(stable_iterator Old) const
class EHCatchScope * pushCatch(unsigned NumHandlers)
Push a set of catch handlers on the stack.
iterator find(stable_iterator save) const
Turn a stable reference to a scope depth into a unstable pointer to the EH stack.
void popNullFixups()
Pops lazily-removed fixups from the end of the list.
bool hasNormalCleanups() const
Determines whether there are any normal cleanups on the stack.
stable_iterator getInnermostActiveNormalCleanup() const
stable_iterator stabilize(iterator it) const
Translates an iterator into a stable_iterator.
static stable_iterator stable_end()
Create a stable reference to the bottom of the EH stack.
void clearFixups()
Clears the branch-fixups list.
void pushTerminate()
Push a terminate handler on the stack.
A protected scope for zero-cost EH handling.
EHScopeStack::stable_iterator getEnclosingEHScope() const
bool hasEHBranches() const
An exceptions scope which calls std::terminate if any exception reaches it.
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
static RValue get(llvm::Value *V)
static RValue getAggregate(Address addr, bool isVolatile=false)
Convert an Address to an RValue.
static RValue getComplex(llvm::Value *V1, llvm::Value *V2)
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
An abstract representation of an aligned address.
llvm::Value * getPointer() const
static RawAddress invalid()
A (possibly-)qualified type.
Scope - A scope is a transient data structure that is used while parsing the program.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
@ NormalCleanup
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
@ EHCleanup
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
bool Load(InterpState &S, CodePtr OpPC)
The JSON file list parser is used to communicate input to InstallAPI.
unsigned DestinationIndex
The destination index value.
llvm::BasicBlock * Destination
The ultimate destination of the branch.
llvm::BasicBlock * OptimisticBranchBlock
The block containing the terminator which needs to be modified into a switch if this fixup is resolve...
llvm::BranchInst * InitialBranch
The initial branch of the fixup.
static llvm::Value * restore(CodeGenFunction &CGF, saved_type value)
static saved_type save(CodeGenFunction &CGF, llvm::Value *value)
static bool needsSaving(llvm::Value *value)
Answer whether the given value needs extra work to be saved.
A metaprogramming class for ensuring that a value will dominate an arbitrary position in a function.
The exceptions personality for a function.
bool isMSVCXXPersonality() const
static const EHPersonality & get(CodeGenModule &CGM, const FunctionDecl *FD)
bool usesFuncletPads() const
Does this personality use landingpads or the family of pad instructions designed to form funclets?
bool isMSVCPersonality() const
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4