21#include "llvm/Support/SaveAndRestore.h"
65 case AggregateLiteral:
66 case AggregateAddress:
69 case ComplexAddress: {
76 llvm_unreachable(
"bad saved r-value kind");
80char *EHScopeStack::allocate(
size_t Size) {
83 unsigned Capacity = 1024;
84 while (Capacity < Size) Capacity *= 2;
85 StartOfBuffer =
new char[Capacity];
86 StartOfData = EndOfBuffer = StartOfBuffer + Capacity;
87 }
else if (
static_cast<size_t>(StartOfData - StartOfBuffer) < Size) {
88 unsigned CurrentCapacity = EndOfBuffer - StartOfBuffer;
89 unsigned UsedCapacity = CurrentCapacity - (StartOfData - StartOfBuffer);
91 unsigned NewCapacity = 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;
101 StartOfBuffer = NewStartOfBuffer;
102 EndOfBuffer = NewEndOfBuffer;
103 StartOfData = NewStartOfData;
106 assert(StartOfBuffer + Size <= StartOfData);
111void EHScopeStack::deallocate(
size_t Size) {
117 for (EHScopeStack::iterator it =
begin();
stabilize(it) != Old; it++) {
118 EHCleanupScope *
cleanup = dyn_cast<EHCleanupScope>(&*it);
133 if (
auto *cleanup = dyn_cast<EHCleanupScope>(&*
find(si)))
134 if (
cleanup->isLifetimeMarker()) {
135 si =
cleanup->getEnclosingEHScope();
149 if (
cleanup.isActive())
return si;
150 si =
cleanup.getEnclosingNormalCleanup();
156void *EHScopeStack::pushCleanup(
CleanupKind Kind,
size_t Size) {
173 EHCleanupScope *Scope =
174 new (Buffer) EHCleanupScope(IsNormalCleanup,
178 InnermostNormalCleanup,
184 if (IsLifetimeMarker)
188 if (IsSEHFinallyCleanup)
199 if (CGF->getLangOpts().EHAsynch && IsEHCleanup && !IsLifetimeMarker &&
200 !IsSEHFinallyCleanup && CGF->getTarget().getCXXABI().isMicrosoft() &&
201 CGF->getInvokeDest())
202 CGF->EmitSehCppScopeBegin();
208 assert(!
empty() &&
"popping exception stack when not empty");
220 if (!BranchFixups.empty()) {
224 BranchFixups.clear();
235 EHFilterScope *filter =
new (buffer) EHFilterScope(numFilters);
241 assert(!
empty() &&
"popping exception stack when not empty");
251 EHCatchScope *scope =
252 new (buffer) EHCatchScope(numHandlers, InnermostEHScope);
259 new (Buffer) EHTerminateScope(InnermostEHScope);
273 EHScopeStack::iterator it =
find(InnermostNormalCleanup);
275 assert(BranchFixups.size() >= MinSize &&
"fixup stack out of order");
277 while (BranchFixups.size() > MinSize &&
278 BranchFixups.back().Destination ==
nullptr)
279 BranchFixups.pop_back();
300 assert(!cleanup.hasActiveFlag() &&
"cleanup already has active flag?");
301 cleanup.setActiveFlag(ActiveFlag);
303 if (cleanup.isNormalCleanup()) cleanup.setTestFlagInNormalCleanup();
304 if (cleanup.isEHCleanup()) cleanup.setTestFlagInEHCleanup();
307void EHScopeStack::Cleanup::anchor() {}
310 llvm::BasicBlock::iterator beforeInst,
312 auto store =
new llvm::StoreInst(value, addr.
emitRawPointer(CGF), beforeInst);
316static llvm::LoadInst *
318 llvm::BasicBlock::iterator beforeInst,
336 llvm::BasicBlock *CleanupEntry) {
373 llvm::BasicBlock *
Block) {
376 llvm::Instruction *Term =
Block->getTerminator();
378 if (llvm::UncondBrInst *Br = dyn_cast<llvm::UncondBrInst>(Term)) {
380 "cleanup.dest", Term->getIterator(), CGF);
381 llvm::SwitchInst *
Switch =
382 llvm::SwitchInst::Create(Load, Br->getSuccessor(0), 4,
Block);
383 Br->eraseFromParent();
391 assert(
Block &&
"resolving a null target block");
392 if (!
EHStack.getNumBranchFixups())
return;
394 assert(
EHStack.hasNormalCleanups() &&
395 "branch fixups exist with no normal cleanups on stack");
398 bool ResolvedAny =
false;
400 for (
unsigned I = 0, E =
EHStack.getNumBranchFixups(); I != E; ++I) {
415 if (!ModifiedOptimisticBlocks.insert(BranchBB).second)
431 std::initializer_list<llvm::Value **> ValuesToReload) {
434 bool HadBranches =
false;
435 while (
EHStack.stable_begin() != Old) {
437 HadBranches |=
Scope.hasBranches();
442 bool FallThroughIsBranchThrough =
456 for (llvm::Value **ReloadedValue : ValuesToReload) {
457 auto *Inst = dyn_cast_or_null<llvm::Instruction>(*ReloadedValue);
463 auto *AI = dyn_cast<llvm::AllocaInst>(Inst);
464 if (AI && AI->isStaticAlloca())
471 llvm::BasicBlock::iterator InsertBefore;
472 if (
auto *Invoke = dyn_cast<llvm::InvokeInst>(Inst))
473 InsertBefore = Invoke->getNormalDest()->getFirstInsertionPt();
475 InsertBefore = std::next(Inst->getIterator());
479 *ReloadedValue =
Builder.CreateLoad(Tmp);
487 std::initializer_list<llvm::Value **> ValuesToReload) {
491 for (
size_t I = OldLifetimeExtendedSize,
495 "misaligned cleanup stack entry");
511 I +=
sizeof(ActiveFlag);
519 assert(
Scope.isNormalCleanup());
520 llvm::BasicBlock *Entry =
Scope.getNormalBlock();
523 Scope.setNormalBlock(Entry);
534 llvm::BasicBlock *Entry) {
535 llvm::BasicBlock *Pred = Entry->getSinglePredecessor();
536 if (!Pred)
return Entry;
538 llvm::UncondBrInst *Br = dyn_cast<llvm::UncondBrInst>(Pred->getTerminator());
541 assert(Br->getSuccessor() == Entry);
546 bool WasInsertBlock = CGF.
Builder.GetInsertBlock() == Entry;
547 assert(!WasInsertBlock || CGF.
Builder.GetInsertPoint() == Entry->end());
550 Br->eraseFromParent();
554 Entry->replaceAllUsesWith(Pred);
557 Pred->splice(Pred->end(), Entry);
560 Entry->eraseFromParent();
563 CGF.
Builder.SetInsertPoint(Pred);
569 EHScopeStack::Cleanup *Fn,
570 EHScopeStack::Cleanup::Flags flags,
574 llvm::BasicBlock *ContBB =
nullptr;
578 llvm::Value *IsActive
580 CGF.
Builder.CreateCondBr(IsActive, CleanupBB, ContBB);
585 Fn->Emit(CGF, flags);
586 assert(CGF.
HaveInsertPoint() &&
"cleanup ended with no insertion point?");
594 llvm::BasicBlock *From,
595 llvm::BasicBlock *To) {
598 llvm::Instruction *Term = Exit->getTerminator();
600 if (llvm::UncondBrInst *Br = dyn_cast<llvm::UncondBrInst>(Term)) {
601 assert(Br->getSuccessor() == From);
602 Br->setSuccessor(To);
605 for (
unsigned I = 0, E =
Switch->getNumSuccessors(); I != E; ++I)
606 if (
Switch->getSuccessor(I) == From)
607 Switch->setSuccessor(I, To);
624 for (llvm::BasicBlock::use_iterator
625 i = entry->use_begin(), e = entry->use_end(); i != e; ) {
629 use.set(unreachableBB);
633 if (si->getNumCases() == 1 && si->getDefaultDest() == unreachableBB) {
635 llvm::UncondBrInst::Create(si->case_begin()->getCaseSuccessor(),
642 si->eraseFromParent();
651 assert(entry->use_empty());
660 assert(!
EHStack.empty() &&
"cleanup stack is empty!");
663 assert(
Scope.getFixupDepth() <=
EHStack.getNumBranchFixups());
667 CGBuilderTy::InsertPoint NormalDeactivateOrigIP;
669 NormalDeactivateOrigIP =
Builder.saveAndClearIP();
672 bool IsActive =
Scope.isActive();
674 Scope.shouldTestFlagInNormalCleanup() ?
Scope.getActiveFlag()
677 Scope.shouldTestFlagInEHCleanup() ?
Scope.getActiveFlag()
682 llvm::BasicBlock *EHEntry =
Scope.getCachedEHDispatchBlock();
683 assert(
Scope.hasEHBranches() == (EHEntry !=
nullptr));
684 bool RequiresEHCleanup = (EHEntry !=
nullptr);
690 unsigned FixupDepth =
Scope.getFixupDepth();
691 bool HasFixups =
EHStack.getNumBranchFixups() != FixupDepth;
694 bool HasExistingBranches =
Scope.hasBranches();
697 llvm::BasicBlock *FallthroughSource =
Builder.GetInsertBlock();
698 bool HasFallthrough =
699 FallthroughSource !=
nullptr && (IsActive || HasExistingBranches);
705 bool HasPrebranchedFallthrough =
706 (FallthroughSource && FallthroughSource->hasTerminator());
711 assert(!
Scope.isNormalCleanup() || !HasPrebranchedFallthrough ||
712 (
Scope.getNormalBlock() &&
713 FallthroughSource->getTerminator()->getSuccessor(0)
714 ==
Scope.getNormalBlock()));
716 bool RequiresNormalCleanup =
false;
717 if (
Scope.isNormalCleanup() &&
718 (HasFixups || HasExistingBranches || HasFallthrough)) {
719 RequiresNormalCleanup =
true;
724 if (
Scope.isNormalCleanup() && HasPrebranchedFallthrough &&
725 !RequiresNormalCleanup) {
729 llvm::BasicBlock *prebranchDest;
734 if (FallthroughIsBranchThrough) {
747 llvm::BasicBlock *normalEntry =
Scope.getNormalBlock();
748 assert(normalEntry && !normalEntry->use_empty());
751 normalEntry, prebranchDest);
755 if (!RequiresNormalCleanup && !RequiresEHCleanup) {
758 assert(
EHStack.getNumBranchFixups() == 0 ||
760 if (NormalDeactivateOrigIP.isSet())
761 Builder.restoreIP(NormalDeactivateOrigIP);
770 auto *CleanupSource =
reinterpret_cast<char *
>(
Scope.getCleanupBuffer());
772 CleanupBufferStack[8 *
sizeof(
void *)];
773 std::unique_ptr<char[]> CleanupBufferHeap;
774 size_t CleanupSize =
Scope.getCleanupSize();
775 EHScopeStack::Cleanup *Fn;
777 if (CleanupSize <=
sizeof(CleanupBufferStack)) {
778 memcpy(CleanupBufferStack, CleanupSource, CleanupSize);
779 Fn =
reinterpret_cast<EHScopeStack::Cleanup *
>(CleanupBufferStack);
781 CleanupBufferHeap.reset(
new char[CleanupSize]);
782 memcpy(CleanupBufferHeap.get(), CleanupSource, CleanupSize);
783 Fn =
reinterpret_cast<EHScopeStack::Cleanup *
>(CleanupBufferHeap.get());
786 EHScopeStack::Cleanup::Flags cleanupFlags;
787 if (
Scope.isNormalCleanup())
788 cleanupFlags.setIsNormalCleanupKind();
789 if (
Scope.isEHCleanup())
790 cleanupFlags.setIsEHCleanupKind();
794 bool IsSEHFinallyCleanup =
Scope.isSEHFinallyCleanup();
795 if (!RequiresNormalCleanup) {
802 if (NormalDeactivateOrigIP.isSet())
803 Builder.restoreIP(NormalDeactivateOrigIP);
804 if (
Builder.GetInsertBlock() && !IsSEHFinallyCleanup)
806 if (NormalDeactivateOrigIP.isSet())
807 NormalDeactivateOrigIP =
Builder.saveAndClearIP();
815 if (HasFallthrough && !HasPrebranchedFallthrough && !HasFixups &&
816 !HasExistingBranches) {
820 if (
Scope.isSEHFinallyCleanup())
830 EmitCleanup(*
this, Fn, cleanupFlags, NormalActiveFlag);
840 CGBuilderTy::InsertPoint savedInactiveFallthroughIP;
844 if (HasFallthrough) {
845 if (!HasPrebranchedFallthrough)
850 }
else if (FallthroughSource) {
851 assert(!IsActive &&
"source without fallthrough for active cleanup");
852 savedInactiveFallthroughIP =
Builder.saveAndClearIP();
862 if (
Scope.isSEHFinallyCleanup())
871 bool HasEnclosingCleanups =
872 (
Scope.getEnclosingNormalCleanup() !=
EHStack.stable_end());
879 llvm::BasicBlock *BranchThroughDest =
nullptr;
880 if (
Scope.hasBranchThroughs() ||
881 (FallthroughSource && FallthroughIsBranchThrough) ||
882 (HasFixups && HasEnclosingCleanups)) {
883 assert(HasEnclosingCleanups);
888 llvm::BasicBlock *FallthroughDest =
nullptr;
898 if (!
Scope.hasBranchThroughs() && !HasFixups && !HasFallthrough &&
900 assert(!BranchThroughDest || !IsActive);
903 llvm::Instruction *NormalCleanupDestSlot =
905 if (NormalCleanupDestSlot->hasOneUse()) {
906 NormalCleanupDestSlot->user_back()->eraseFromParent();
907 NormalCleanupDestSlot->eraseFromParent();
911 llvm::BasicBlock *BranchAfter =
Scope.getBranchAfterBlock(0);
912 InstsToAppend.push_back(llvm::UncondBrInst::Create(BranchAfter));
919 }
else if (
Scope.getNumBranchAfters() ||
920 (HasFallthrough && !FallthroughIsBranchThrough) ||
921 (HasFixups && !HasEnclosingCleanups)) {
927 const unsigned SwitchCapacity = 10;
930 cleanupFlags.setHasExitSwitch();
933 "cleanup.dest", *
this);
934 llvm::SwitchInst *
Switch =
935 llvm::SwitchInst::Create(Load,
Default, SwitchCapacity);
937 InstsToAppend.push_back(Load);
938 InstsToAppend.push_back(
Switch);
941 if (FallthroughSource && !FallthroughIsBranchThrough) {
947 for (
unsigned I = 0, E =
Scope.getNumBranchAfters(); I != E; ++I) {
949 Scope.getBranchAfterBlock(I));
954 if (HasFixups && !HasEnclosingCleanups)
958 assert(BranchThroughDest);
959 InstsToAppend.push_back(llvm::UncondBrInst::Create(BranchThroughDest));
965 assert(
EHStack.hasNormalCleanups() == HasEnclosingCleanups);
967 EmitCleanup(*
this, Fn, cleanupFlags, NormalActiveFlag);
970 llvm::BasicBlock *NormalExit =
Builder.GetInsertBlock();
971 for (llvm::Instruction *Inst : InstsToAppend)
972 Inst->insertInto(NormalExit, NormalExit->end());
975 for (
unsigned I = FixupDepth, E =
EHStack.getNumBranchFixups();
993 if (!HasFallthrough && FallthroughSource) {
998 Builder.restoreIP(savedInactiveFallthroughIP);
1003 }
else if (HasFallthrough && FallthroughDest) {
1004 assert(!FallthroughIsBranchThrough);
1009 }
else if (HasFallthrough) {
1014 Builder.ClearInsertionPoint();
1021 llvm::BasicBlock *NewNormalEntry =
1026 if (NewNormalEntry != NormalEntry && NormalEntry == NormalExit)
1027 for (
unsigned I = FixupDepth, E =
EHStack.getNumBranchFixups();
1029 EHStack.getBranchFixup(I).OptimisticBranchBlock = NewNormalEntry;
1033 if (NormalDeactivateOrigIP.isSet())
1034 Builder.restoreIP(NormalDeactivateOrigIP);
1035 assert(
EHStack.hasNormalCleanups() ||
EHStack.getNumBranchFixups() == 0);
1038 if (RequiresEHCleanup) {
1039 CGBuilderTy::InsertPoint SavedIP =
Builder.saveAndClearIP();
1048 bool PushedTerminate =
false;
1050 llvm::CleanupPadInst *CPI =
nullptr;
1056 ParentPad = llvm::ConstantTokenNone::get(
CGM.getLLVMContext());
1063 PushedTerminate =
true;
1065 if (!IsSEHFinallyCleanup)
1071 if (EHActiveFlag.
isValid() || IsActive) {
1072 cleanupFlags.setIsForEHCleanup();
1073 EmitCleanup(*
this, Fn, cleanupFlags, EHActiveFlag);
1077 Builder.CreateCleanupRet(CPI, NextAction);
1082 if (PushedTerminate)
1096 &&
"stale jump destination");
1100 EHStack.getInnermostActiveNormalCleanup();
1105 if (TopCleanup ==
EHStack.stable_end() ||
1121 &&
"stale jump destination");
1132 TopCleanup =
EHStack.getInnermostActiveNormalCleanup();
1137 if (TopCleanup ==
EHStack.stable_end() ||
1139 Builder.ClearInsertionPoint();
1152 Builder.ClearInsertionPoint();
1176 assert(
Scope.isNormalCleanup());
1177 I =
Scope.getEnclosingNormalCleanup();
1194 Builder.ClearInsertionPoint();
1198 EHScopeStack::stable_iterator cleanup) {
1204 for (EHScopeStack::stable_iterator
1206 assert(cleanup.strictlyEncloses(i));
1229 EHScopeStack::stable_iterator
C,
1231 llvm::Instruction *dominatingIP) {
1237 bool isActivatedInConditional =
1240 bool needFlag =
false;
1245 if (
Scope.isNormalCleanup()) {
1246 Scope.setTestFlagInNormalCleanup();
1251 if (
Scope.isEHCleanup() &&
1253 Scope.setTestFlagInEHCleanup();
1262 if (!var.isValid()) {
1266 Scope.setActiveFlag(var);
1267 Scope.AddAuxAllocas(AllocaTracker.
Take());
1269 assert(dominatingIP &&
"no existing variable and no dominating IP!");
1289 llvm::Instruction *dominatingIP) {
1290 assert(
C !=
EHStack.stable_end() &&
"activating bottom of stack?");
1292 assert(!
Scope.isActive() &&
"double activation");
1296 Scope.setActive(
true);
1301 llvm::Instruction *dominatingIP) {
1302 assert(
C !=
EHStack.stable_end() &&
"deactivating bottom of stack?");
1304 assert(
Scope.isActive() &&
"double deactivation");
1318 Scope.setActive(
false);
1339 llvm::FunctionCallee &SehCppScope) {
1341 assert(CGF.
Builder.GetInsertBlock() && InvokeDest);
1347 CGF.
Builder.CreateInvoke(SehCppScope, Cont, InvokeDest, {}, BundleList);
1354 llvm::FunctionCallee SehCppScope =
1355 CGM.getIntrinsic(llvm::Intrinsic::seh_scope_begin);
1363 llvm::FunctionCallee SehCppScope =
1364 CGM.getIntrinsic(llvm::Intrinsic::seh_scope_end);
1371 llvm::FunctionCallee SehCppScope =
1372 CGM.getIntrinsic(llvm::Intrinsic::seh_try_begin);
1379 llvm::FunctionCallee SehCppScope =
1380 CGM.getIntrinsic(llvm::Intrinsic::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)
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a an optional score condition
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
__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...
EHScopeStack::stable_iterator CurrentCleanupScopeDepth
void EmitSehCppScopeBegin()
void ActivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
ActivateCleanupBlock - Activates an initially-inactive cleanup.
void EmitSehTryScopeEnd()
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
void addInstToCurrentSourceAtom(llvm::Instruction *KeyInstruction, llvm::Value *Backup)
See CGDebugInfo::addInstToCurrentSourceAtom.
const LangOptions & getLangOpts() const
void pushDestroy(QualType::DestructionKind dtorKind, Address addr, QualType type)
pushDestroy - Push the standard destructor for the given type as at least a normal cleanup.
static Destroyer destroyCXXObject
void EmitSehCppScopeEnd()
void EmitBranchThroughCleanup(JumpDest Dest)
EmitBranchThroughCleanup - Emit a branch from the current insert block through the normal cleanup han...
llvm::BasicBlock * getUnreachableBlock()
bool currentFunctionUsesSEHTry() const
@ Default
! No language constraints on evaluation order.
void initFullExprCleanupWithFlag(RawAddress ActiveFlag)
RawAddress CreateDefaultAlignTempAlloca(llvm::Type *Ty, const Twine &Name="tmp")
CreateDefaultAlignedTempAlloca - This creates an alloca with the default ABI alignment of the given L...
bool isInConditionalBranch() const
isInConditionalBranch - Return true if we're currently emitting one branch or the other of a conditio...
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.
void DeactivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
DeactivateCleanupBlock - Deactivates the given cleanup block.
llvm::BasicBlock * getInvokeDest()
void ResolveBranchFixups(llvm::BasicBlock *Target)
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
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...
void EmitSehTryScopeBegin()
void setBeforeOutermostConditional(llvm::Value *value, Address addr, CodeGenFunction &CGF)
SmallVector< llvm::OperandBundleDef, 1 > getBundlesForFunclet(llvm::Value *Callee)
RawAddress CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits align, const Twine &Name="tmp", llvm::Value *ArraySize=nullptr)
CreateTempAlloca - This creates a alloca and inserts it into the entry block.
llvm::SmallVector< char, 256 > LifetimeExtendedCleanupStack
RawAddress getNormalCleanupDestSlot()
void EmitCXXTemporary(const CXXTemporary *Temporary, QualType TempType, Address Ptr)
Emits all the code to cause the given temporary to be cleaned up.
llvm::BasicBlock * getEHDispatchBlock(EHScopeStack::stable_iterator scope)
RawAddress NormalCleanupDest
i32s containing the indexes of the cleanup destinations.
RawAddress createCleanupActiveFlag()
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
llvm::Instruction * CurrentFuncletPad
bool isObviouslyBranchWithoutCleanups(JumpDest Dest) const
isObviouslyBranchWithoutCleanups - Return true if a branch to the specified destination obviously has...
void PopCleanupBlock(bool FallThroughIsBranchThrough=false, bool ForDeactivation=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
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.
void setSEHFinallyCleanup()
EHScopeStack::stable_iterator getEnclosingNormalCleanup() const
size_t getAllocatedSize() const
void * getCleanupBuffer()
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
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.
void popNullFixups()
Pops lazily-removed fixups from the end of the list.
BranchFixup & getBranchFixup(unsigned I)
bool requiresLandingPad() const
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
class EHFilterScope * pushFilter(unsigned NumFilters)
Push an exceptions filter on the stack.
stable_iterator getInnermostEHScope() const
bool empty() const
Determines whether the exception-scopes stack is empty.
bool containsOnlyNoopCleanups(stable_iterator Old) const
iterator begin() const
Returns an iterator pointing to the innermost EH scope.
void pushTerminate()
Push a terminate handler on the stack.
void popCleanup()
Pops a cleanup scope off the stack. This is private to CGCleanup.cpp.
iterator find(stable_iterator save) const
Turn a stable reference to a scope depth into a unstable pointer to the EH stack.
stable_iterator getInnermostActiveNormalCleanup() const
void popFilter()
Pops an exceptions filter off the stack.
bool hasNormalCleanups() const
Determines whether there are any normal cleanups on the stack.
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.
class EHCatchScope * pushCatch(unsigned NumHandlers)
Push a set of catch handlers on the stack.
A protected scope for zero-cost EH handling.
EHScopeStack::stable_iterator getEnclosingEHScope() const
bool hasEHBranches() const
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.
@ 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...
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
U cast(CodeGen::Address addr)
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::UncondBrInst * InitialBranch
The initial branch of the fixup.
llvm::SmallVector< llvm::AllocaInst * > Take()
A jump destination is an abstract label, branching to which may require a jump out through normal cle...
llvm::BasicBlock * getBlock() const
EHScopeStack::stable_iterator getScopeDepth() const
unsigned getDestIndex() const
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.
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