21 #include "llvm/Support/SaveAndRestore.h" 23 using namespace clang;
24 using namespace CodeGen;
41 return saved_type(V, ScalarLiteral);
47 return saved_type(addr.
getPointer(), ScalarAddress);
53 llvm::StructType::get(V.first->getType(), V.second->getType());
57 return saved_type(addr.getPointer(), ComplexAddress);
63 return saved_type(V.getPointer(), AggregateLiteral,
64 V.getAlignment().getQuantity());
69 return saved_type(addr.getPointer(), AggregateAddress,
70 V.getAlignment().getQuantity());
78 auto alignment = cast<llvm::AllocaInst>(value)->getAlignment();
86 case AggregateLiteral:
88 case AggregateAddress: {
92 case ComplexAddress: {
102 llvm_unreachable(
"bad saved r-value kind");
106 char *EHScopeStack::allocate(
size_t Size) {
108 if (!StartOfBuffer) {
109 unsigned Capacity = 1024;
110 while (Capacity < Size) Capacity *= 2;
111 StartOfBuffer =
new char[Capacity];
112 StartOfData = EndOfBuffer = StartOfBuffer + Capacity;
113 }
else if (static_cast<size_t>(StartOfData - StartOfBuffer) < Size) {
114 unsigned CurrentCapacity = EndOfBuffer - StartOfBuffer;
115 unsigned UsedCapacity = CurrentCapacity - (StartOfData - StartOfBuffer);
117 unsigned NewCapacity = CurrentCapacity;
120 }
while (NewCapacity < UsedCapacity + Size);
122 char *NewStartOfBuffer =
new char[NewCapacity];
123 char *NewEndOfBuffer = NewStartOfBuffer + NewCapacity;
124 char *NewStartOfData = NewEndOfBuffer - UsedCapacity;
125 memcpy(NewStartOfData, StartOfData, UsedCapacity);
126 delete [] StartOfBuffer;
127 StartOfBuffer = NewStartOfBuffer;
128 EndOfBuffer = NewEndOfBuffer;
129 StartOfData = NewStartOfData;
132 assert(StartOfBuffer + Size <= StartOfData);
137 void EHScopeStack::deallocate(
size_t Size) {
155 if (
auto *
cleanup = dyn_cast<EHCleanupScope>(&*
find(si)))
156 if (
cleanup->isLifetimeMarker()) {
157 si =
cleanup->getEnclosingEHScope();
190 InnermostNormalCleanup,
196 if (IsLifetimeMarker)
203 assert(!
empty() &&
"popping exception stack when not empty");
205 assert(isa<EHCleanupScope>(*
begin()));
215 if (!BranchFixups.empty()) {
219 BranchFixups.clear();
236 assert(!
empty() &&
"popping exception stack when not empty");
247 new (buffer)
EHCatchScope(numHandlers, InnermostEHScope);
269 unsigned MinSize = cast<EHCleanupScope>(*it).getFixupDepth();
270 assert(BranchFixups.size() >= MinSize &&
"fixup stack out of order");
272 while (BranchFixups.size() > MinSize &&
273 BranchFixups.back().Destination ==
nullptr)
274 BranchFixups.pop_back();
279 Address active = CreateTempAllocaWithoutCast(
284 setBeforeOutermostConditional(Builder.getFalse(), active);
287 Builder.CreateStore(Builder.getTrue(), active);
295 assert(!cleanup.
hasActiveFlag() &&
"cleanup already has active flag?");
302 void EHScopeStack::Cleanup::anchor() {}
305 llvm::Instruction *beforeInst) {
306 auto store =
new llvm::StoreInst(value, addr.
getPointer(), beforeInst);
311 llvm::Instruction *beforeInst) {
312 auto load =
new llvm::LoadInst(addr.
getPointer(),
name, beforeInst);
321 llvm::SwitchInst *Switch,
322 llvm::BasicBlock *CleanupEntry) {
323 llvm::SmallPtrSet<llvm::BasicBlock*, 4> CasesAdded;
359 llvm::BasicBlock *Block) {
362 llvm::Instruction *Term = Block->getTerminator();
363 assert(Term &&
"can't transition block without terminator");
365 if (llvm::BranchInst *Br = dyn_cast<llvm::BranchInst>(Term)) {
366 assert(Br->isUnconditional());
368 "cleanup.dest", Term);
369 llvm::SwitchInst *Switch =
371 Br->eraseFromParent();
374 return cast<llvm::SwitchInst>(Term);
379 assert(Block &&
"resolving a null target block");
380 if (!EHStack.getNumBranchFixups())
return;
382 assert(EHStack.hasNormalCleanups() &&
383 "branch fixups exist with no normal cleanups on stack");
385 llvm::SmallPtrSet<llvm::BasicBlock*, 4> ModifiedOptimisticBlocks;
386 bool ResolvedAny =
false;
388 for (
unsigned I = 0, E = EHStack.getNumBranchFixups(); I != E; ++I) {
403 if (!ModifiedOptimisticBlocks.insert(BranchBB).second)
413 EHStack.popNullFixups();
419 std::initializer_list<llvm::Value **> ValuesToReload) {
422 bool HadBranches =
false;
423 while (EHStack.stable_begin() != Old) {
430 bool FallThroughIsBranchThrough =
433 PopCleanupBlock(FallThroughIsBranchThrough);
444 for (
llvm::Value **ReloadedValue : ValuesToReload) {
445 auto *Inst = dyn_cast_or_null<llvm::Instruction>(*ReloadedValue);
451 auto *AI = dyn_cast<llvm::AllocaInst>(Inst);
452 if (AI && AI->isStaticAlloca())
456 CreateDefaultAlignTempAlloca(Inst->getType(),
"tmp.exprcleanup");
459 llvm::BasicBlock::iterator InsertBefore;
460 if (
auto *Invoke = dyn_cast<llvm::InvokeInst>(Inst))
461 InsertBefore = Invoke->getNormalDest()->getFirstInsertionPt();
463 InsertBefore = std::next(Inst->getIterator());
467 *ReloadedValue = Builder.CreateLoad(Tmp);
475 std::initializer_list<llvm::Value **> ValuesToReload) {
476 PopCleanupBlocks(Old, ValuesToReload);
479 for (
size_t I = OldLifetimeExtendedSize,
480 E = LifetimeExtendedCleanupStack.size(); I != E; ) {
483 "misaligned cleanup stack entry");
487 LifetimeExtendedCleanupStack[I]);
490 EHStack.pushCopyOfCleanup(Header.
getKind(),
491 &LifetimeExtendedCleanupStack[I],
497 reinterpret_cast<Address &
>(LifetimeExtendedCleanupStack[I]);
498 initFullExprCleanupWithFlag(ActiveFlag);
499 I +=
sizeof(ActiveFlag);
502 LifetimeExtendedCleanupStack.resize(OldLifetimeExtendedSize);
522 llvm::BasicBlock *Entry) {
523 llvm::BasicBlock *Pred = Entry->getSinglePredecessor();
524 if (!Pred)
return Entry;
526 llvm::BranchInst *Br = dyn_cast<llvm::BranchInst>(Pred->getTerminator());
527 if (!Br || Br->isConditional())
return Entry;
528 assert(Br->getSuccessor(0) == Entry);
533 bool WasInsertBlock = CGF.
Builder.GetInsertBlock() == Entry;
534 assert(!WasInsertBlock || CGF.
Builder.GetInsertPoint() == Entry->end());
537 Br->eraseFromParent();
541 Entry->replaceAllUsesWith(Pred);
544 Pred->getInstList().splice(Pred->end(), Entry->getInstList());
547 Entry->eraseFromParent();
550 CGF.
Builder.SetInsertPoint(Pred);
561 llvm::BasicBlock *ContBB =
nullptr;
567 CGF.
Builder.CreateCondBr(IsActive, CleanupBB, ContBB);
572 Fn->
Emit(CGF, flags);
573 assert(CGF.
HaveInsertPoint() &&
"cleanup ended with no insertion point?");
581 llvm::BasicBlock *From,
582 llvm::BasicBlock *To) {
585 llvm::Instruction *Term = Exit->getTerminator();
587 if (llvm::BranchInst *Br = dyn_cast<llvm::BranchInst>(Term)) {
588 assert(Br->isUnconditional() && Br->getSuccessor(0) == From);
589 Br->setSuccessor(0, To);
591 llvm::SwitchInst *Switch = cast<llvm::SwitchInst>(Term);
592 for (
unsigned I = 0, E = Switch->getNumSuccessors(); I != E; ++I)
593 if (Switch->getSuccessor(I) == From)
594 Switch->setSuccessor(I, To);
611 for (llvm::BasicBlock::use_iterator
612 i = entry->use_begin(), e = entry->use_end(); i != e; ) {
616 use.set(unreachableBB);
619 llvm::SwitchInst *si = cast<llvm::SwitchInst>(use.getUser());
620 if (si->getNumCases() == 1 && si->getDefaultDest() == unreachableBB) {
625 llvm::LoadInst *condition = cast<llvm::LoadInst>(si->getCondition());
628 si->eraseFromParent();
632 assert(condition->use_empty());
633 condition->eraseFromParent();
637 assert(entry->use_empty());
645 assert(!EHStack.empty() &&
"cleanup stack is empty!");
646 assert(isa<EHCleanupScope>(*EHStack.begin()) &&
"top not a cleanup!");
648 assert(Scope.
getFixupDepth() <= EHStack.getNumBranchFixups());
663 bool RequiresEHCleanup = (EHEntry !=
nullptr);
670 bool HasFixups = EHStack.getNumBranchFixups() != FixupDepth;
676 llvm::BasicBlock *FallthroughSource = Builder.GetInsertBlock();
677 bool HasFallthrough = (FallthroughSource !=
nullptr && IsActive);
683 bool HasPrebranchedFallthrough =
684 (FallthroughSource && FallthroughSource->getTerminator());
691 FallthroughSource->getTerminator()->getSuccessor(0)
694 bool RequiresNormalCleanup =
false;
696 (HasFixups || HasExistingBranches || HasFallthrough)) {
697 RequiresNormalCleanup =
true;
702 if (Scope.
isNormalCleanup() && HasPrebranchedFallthrough && !IsActive) {
703 llvm::BasicBlock *prebranchDest;
708 if (FallthroughIsBranchThrough) {
717 prebranchDest = createBasicBlock(
"forwarded-prebranch");
718 EmitBlock(prebranchDest);
722 assert(normalEntry && !normalEntry->use_empty());
725 normalEntry, prebranchDest);
729 if (!RequiresNormalCleanup && !RequiresEHCleanup) {
731 EHStack.popCleanup();
732 assert(EHStack.getNumBranchFixups() == 0 ||
733 EHStack.hasNormalCleanups());
744 CleanupBufferStack[8 *
sizeof(
void *)];
745 std::unique_ptr<char[]> CleanupBufferHeap;
749 if (CleanupSize <=
sizeof(CleanupBufferStack)) {
750 memcpy(CleanupBufferStack, CleanupSource, CleanupSize);
753 CleanupBufferHeap.reset(
new char[CleanupSize]);
754 memcpy(CleanupBufferHeap.get(), CleanupSource, CleanupSize);
764 if (!RequiresNormalCleanup) {
766 EHStack.popCleanup();
770 if (HasFallthrough && !HasPrebranchedFallthrough &&
771 !HasFixups && !HasExistingBranches) {
774 EHStack.popCleanup();
776 EmitCleanup(*
this, Fn, cleanupFlags, NormalActiveFlag);
786 CGBuilderTy::InsertPoint savedInactiveFallthroughIP;
790 if (HasFallthrough) {
791 if (!HasPrebranchedFallthrough)
792 Builder.CreateStore(Builder.getInt32(0), getNormalCleanupDestSlot());
796 }
else if (FallthroughSource) {
797 assert(!IsActive &&
"source without fallthrough for active cleanup");
798 savedInactiveFallthroughIP = Builder.saveAndClearIP();
804 EmitBlock(NormalEntry);
809 bool HasEnclosingCleanups =
817 llvm::BasicBlock *BranchThroughDest =
nullptr;
819 (FallthroughSource && FallthroughIsBranchThrough) ||
820 (HasFixups && HasEnclosingCleanups)) {
821 assert(HasEnclosingCleanups);
826 llvm::BasicBlock *FallthroughDest =
nullptr;
833 assert(!BranchThroughDest || !IsActive);
836 llvm::Instruction *NormalCleanupDestSlot =
837 cast<llvm::Instruction>(getNormalCleanupDestSlot().getPointer());
838 if (NormalCleanupDestSlot->hasOneUse()) {
839 NormalCleanupDestSlot->user_back()->eraseFromParent();
840 NormalCleanupDestSlot->eraseFromParent();
853 (HasFallthrough && !FallthroughIsBranchThrough) ||
854 (HasFixups && !HasEnclosingCleanups)) {
857 (BranchThroughDest ? BranchThroughDest : getUnreachableBlock());
860 const unsigned SwitchCapacity = 10;
862 llvm::LoadInst *
Load =
865 llvm::SwitchInst *Switch =
868 InstsToAppend.push_back(Load);
869 InstsToAppend.push_back(Switch);
872 if (FallthroughSource && !FallthroughIsBranchThrough) {
873 FallthroughDest = createBasicBlock(
"cleanup.cont");
875 Switch->addCase(Builder.getInt32(0), FallthroughDest);
885 if (HasFixups && !HasEnclosingCleanups)
889 assert(BranchThroughDest);
894 EHStack.popCleanup();
895 assert(EHStack.hasNormalCleanups() == HasEnclosingCleanups);
897 EmitCleanup(*
this, Fn, cleanupFlags, NormalActiveFlag);
900 llvm::BasicBlock *NormalExit = Builder.GetInsertBlock();
901 for (
unsigned I = 0, E = InstsToAppend.size(); I != E; ++I)
902 NormalExit->getInstList().push_back(InstsToAppend[I]);
905 for (
unsigned I = FixupDepth, E = EHStack.getNumBranchFixups();
911 getNormalCleanupDestSlot(),
922 if (!HasFallthrough && FallthroughSource) {
927 Builder.restoreIP(savedInactiveFallthroughIP);
932 }
else if (HasFallthrough && FallthroughDest) {
933 assert(!FallthroughIsBranchThrough);
934 EmitBlock(FallthroughDest);
938 }
else if (HasFallthrough) {
943 Builder.ClearInsertionPoint();
950 llvm::BasicBlock *NewNormalEntry =
955 if (NewNormalEntry != NormalEntry && NormalEntry == NormalExit)
956 for (
unsigned I = FixupDepth, E = EHStack.getNumBranchFixups();
958 EHStack.getBranchFixup(I).OptimisticBranchBlock = NewNormalEntry;
962 assert(EHStack.hasNormalCleanups() || EHStack.getNumBranchFixups() == 0);
965 if (RequiresEHCleanup) {
966 CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();
970 llvm::BasicBlock *NextAction = getEHDispatchBlock(EHParent);
975 bool PushedTerminate =
false;
978 llvm::CleanupPadInst *CPI =
nullptr;
984 ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext());
985 CurrentFuncletPad = CPI = Builder.CreateCleanupPad(ParentPad);
990 EHStack.pushTerminate();
991 PushedTerminate =
true;
996 if (EHActiveFlag.
isValid() || IsActive) {
998 EmitCleanup(*
this, Fn, cleanupFlags, EHActiveFlag);
1002 Builder.CreateCleanupRet(CPI, NextAction);
1004 Builder.CreateBr(NextAction);
1007 if (PushedTerminate)
1008 EHStack.popTerminate();
1010 Builder.restoreIP(SavedIP);
1021 &&
"stale jump destination");
1025 EHStack.getInnermostActiveNormalCleanup();
1030 if (TopCleanup == EHStack.stable_end() ||
1046 &&
"stale jump destination");
1048 if (!HaveInsertPoint())
1052 llvm::BranchInst *BI = Builder.CreateBr(Dest.
getBlock());
1056 TopCleanup = EHStack.getInnermostActiveNormalCleanup();
1061 if (TopCleanup == EHStack.stable_end() ||
1063 Builder.ClearInsertionPoint();
1076 Builder.ClearInsertionPoint();
1083 llvm::ConstantInt *Index = Builder.getInt32(Dest.
getDestIndex());
1089 cast<EHCleanupScope>(*EHStack.find(TopCleanup));
1117 Builder.ClearInsertionPoint();
1123 if (cast<EHCleanupScope>(*EHStack.
find(C)).getNormalBlock())
1132 if (S.getNormalBlock())
return true;
1133 I = S.getEnclosingNormalCleanup();
1151 if (scope.hasEHBranches())
1154 i = scope.getEnclosingEHScope();
1173 llvm::Instruction *dominatingIP) {
1179 bool isActivatedInConditional =
1182 bool needFlag =
false;
1201 if (!needFlag)
return;
1206 "cleanup.isactive");
1209 assert(dominatingIP &&
"no existing variable and no dominating IP!");
1229 llvm::Instruction *dominatingIP) {
1230 assert(C != EHStack.stable_end() &&
"activating bottom of stack?");
1232 assert(!Scope.isActive() &&
"double activation");
1236 Scope.setActive(
true);
1241 llvm::Instruction *dominatingIP) {
1242 assert(C != EHStack.stable_end() &&
"deactivating bottom of stack?");
1244 assert(Scope.isActive() &&
"double deactivation");
1248 if (C == EHStack.stable_begin() &&
1252 CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();
1254 Builder.restoreIP(SavedIP);
1261 Scope.setActive(
false);
1265 if (!NormalCleanupDest.isValid())
1267 CreateDefaultAlignTempAlloca(Builder.getInt32Ty(),
"cleanup.dest.slot");
1268 return NormalCleanupDest;
void pushTerminate()
Push a terminate handler on the stack.
Address CreateStructGEP(Address Addr, unsigned Index, const llvm::Twine &Name="")
static llvm::BasicBlock * CreateNormalEntry(CodeGenFunction &CGF, EHCleanupScope &Scope)
EHScopeStack::stable_iterator getEnclosingEHScope() const
void ActivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
ActivateCleanupBlock - Activates an initially-inactive cleanup.
A (possibly-)qualified type.
bool usesFuncletPads() const
Does this personality use landingpads or the family of pad instructions designed to form funclets...
void setIsEHCleanupKind()
static llvm::LoadInst * createLoadInstBefore(Address addr, const Twine &name, llvm::Instruction *beforeInst)
static void destroyOptimisticNormalEntry(CodeGenFunction &CGF, EHCleanupScope &scope)
We don't need a normal entry block for the given cleanup.
llvm::BasicBlock * getCachedEHDispatchBlock() const
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
void initFullExprCleanupWithFlag(Address ActiveFlag)
static stable_iterator stable_end()
Create a stable reference to the bottom of the EH stack.
bool hasEHBranches() const
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.
iterator find(stable_iterator save) const
Turn a stable reference to a scope depth into a unstable pointer to the EH stack. ...
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
llvm::BasicBlock * getNormalBlock() const
unsigned getNumFilters() const
static bool needsSaving(llvm::Value *value)
Answer whether the given value needs extra work to be saved.
bool empty() const
Determines whether the exception-scopes stack is empty.
bool hasActiveFlag() const
static void EmitCleanup(CodeGenFunction &CGF, EHScopeStack::Cleanup *Fn, EHScopeStack::Cleanup::Flags flags, Address ActiveFlag)
llvm::Value * getPointer() const
iterator begin() const
Returns an iterator pointing to the innermost EH scope.
A protected scope for zero-cost EH handling.
A scope which attempts to handle some, possibly all, types of exceptions.
A jump destination is an abstract label, branching to which may require a jump out through normal cle...
bool addBranchThrough(llvm::BasicBlock *Block)
Add a branch-through to this cleanup scope.
bool isObviouslyBranchWithoutCleanups(JumpDest Dest) const
isObviouslyBranchWithoutCleanups - Return true if a branch to the specified destination obviously has...
static size_t getSizeForCleanupSize(size_t Size)
Gets the size required for a lazy cleanup scope with the given cleanup-data requirements.
An exceptions scope which calls std::terminate if any exception reaches it.
bool isMSVCPersonality() const
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
bool shouldTestFlagInNormalCleanup() const
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
static const EHPersonality & get(CodeGenModule &CGM, const FunctionDecl *FD)
A metaprogramming class for ensuring that a value will dominate an arbitrary position in a function...
unsigned getNumBranchFixups() const
class EHCatchScope * pushCatch(unsigned NumHandlers)
Push a set of catch handlers on the stack.
BranchFixup & getBranchFixup(unsigned I)
bool requiresLandingPad() const
llvm::Align getAsAlign() const
getAsAlign - Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit b...
void setNormalBlock(llvm::BasicBlock *BB)
CharUnits getAlignment() const
Return the alignment of this pointer.
bool hasNormalCleanups() const
Determines whether there are any normal cleanups on the stack.
bool containsOnlyLifetimeMarkers(stable_iterator Old) const
Scope - A scope is a transient data structure that is used while parsing the program.
A stack of scopes which respond to exceptions, including cleanups and catch blocks.
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
bool strictlyEncloses(stable_iterator I) const
Returns true if this scope strictly encloses I: that is, if it encloses I and is not I...
void popFilter()
Pops an exceptions filter off the stack.
CharUnits getPointerAlign() const
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...
Address NormalCleanupDest
i32s containing the indexes of the cleanup destinations.
static bool IsUsedAsEHCleanup(EHScopeStack &EHStack, EHScopeStack::stable_iterator cleanup)
static size_t getSizeForNumHandlers(unsigned N)
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
static CharUnits One()
One - Construct a CharUnits quantity of one.
unsigned getFixupDepth() const
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
static void createStoreInstBefore(llvm::Value *value, Address addr, llvm::Instruction *beforeInst)
unsigned getNumBranchAfters() const
Return the number of unique branch-afters on this scope.
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
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 ...
llvm::BranchInst * InitialBranch
The initial branch of the fixup.
Address CreateDefaultAlignTempAlloca(llvm::Type *Ty, const Twine &Name="tmp")
CreateDefaultAlignedTempAlloca - This creates an alloca with the default ABI alignment of the given L...
Address createCleanupActiveFlag()
EHScopeStack::stable_iterator getScopeDepth() const
void clearFixups()
Clears the branch-fixups list.
stable_iterator getInnermostNormalCleanup() const
Returns the innermost normal cleanup on the stack, or stable_end() if there are no normal cleanups...
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
size_t getCleanupSize() const
llvm::BasicBlock * getBlock() const
void * getCleanupBuffer()
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
llvm::ConstantInt * getBranchAfterIndex(unsigned I) const
void ResolveBranchFixups(llvm::BasicBlock *Target)
void setActiveFlag(Address Var)
stable_iterator stabilize(iterator it) const
Translates an iterator into a stable_iterator.
bool encloses(stable_iterator I) const
Returns true if this scope encloses I.
void setTestFlagInNormalCleanup()
size_t getAllocatedSize() const
llvm::BasicBlock * OptimisticBranchBlock
The block containing the terminator which needs to be modified into a switch if this fixup is resolve...
void popCleanup()
Pops a cleanup scope off the stack. This is private to CGCleanup.cpp.
The l-value was considered opaque, so the alignment was determined from a type.
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 * Destination
The ultimate destination of the branch.
A saved depth on the scope stack.
Represents a C++ temporary.
llvm::BasicBlock * getUnreachableBlock()
void setBeforeOutermostConditional(llvm::Value *value, Address addr)
void DeactivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
DeactivateCleanupBlock - Deactivates the given cleanup block.
unsigned getDestIndex() const
EHScopeStack::stable_iterator getEnclosingNormalCleanup() const
void EmitCXXTemporary(const CXXTemporary *Temporary, QualType TempType, Address Ptr)
Emits all the code to cause the given temporary to be cleaned up.
unsigned DestinationIndex
The destination index value.
void setIsNormalCleanupKind()
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
virtual void Emit(CodeGenFunction &CGF, Flags flags)=0
Emit the cleanup.
static size_t getSizeForNumFilters(unsigned numFilters)
static bool IsUsedAsNormalCleanup(EHScopeStack &EHStack, EHScopeStack::stable_iterator C)
static void ForwardPrebranchedFallthrough(llvm::BasicBlock *Exit, llvm::BasicBlock *From, llvm::BasicBlock *To)
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
class EHFilterScope * pushFilter(unsigned NumFilters)
Push an exceptions filter on the stack.
Dataflow Directional Tag Classes.
static RValue getComplex(llvm::Value *V1, llvm::Value *V2)
void popNullFixups()
Pops lazily-removed fixups from the end of the list.
bool isLifetimeMarker() const
bool shouldTestFlagInEHCleanup() const
void addBranchAfter(llvm::ConstantInt *Index, llvm::BasicBlock *Block)
Add a branch-after to this cleanup scope.
static llvm::BasicBlock * SimplifyCleanupEntry(CodeGenFunction &CGF, llvm::BasicBlock *Entry)
Attempts to reduce a cleanup's entry block to a fallthrough.
bool isInConditionalBranch() const
isInConditionalBranch - Return true if we're currently emitting one branch or the other of a conditio...
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
Address getNormalCleanupDestSlot()
static void SetupCleanupBlockActivation(CodeGenFunction &CGF, EHScopeStack::stable_iterator C, ForActivation_t kind, llvm::Instruction *dominatingIP)
The given cleanup block is changing activation state.
stable_iterator getInnermostActiveNormalCleanup() const
llvm::Value * getAggregatePointer() const
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
bool hasBranches() const
True if this cleanup scope has any branch-afters or branch-throughs.
bool isNormalCleanup() const
Address getActiveFlag() const
The exceptions personality for a function.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
llvm::BasicBlock * getBranchAfterBlock(unsigned I) const
A cleanup scope which generates the cleanup blocks lazily.
stable_iterator getInnermostEHScope() const
bool hasBranchThroughs() const
Determines if this cleanup scope has any branch throughs.
An exceptions scope which filters exceptions thrown through it.
static RValue get(llvm::Value *V)
void EmitBranchThroughCleanup(JumpDest Dest)
EmitBranchThroughCleanup - Emit a branch from the current insert block through the normal cleanup han...
static RValue getAggregate(Address addr, bool isVolatile=false)
bool Load(InterpState &S, CodePtr OpPC)
Information for lazily generating a cleanup.
A non-stable pointer into the scope stack.
void setTestFlagInEHCleanup()
void PopCleanupBlock(bool FallThroughIsBranchThrough=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.