22 #include "llvm/Support/SaveAndRestore.h" 24 using namespace clang;
25 using namespace CodeGen;
42 return saved_type(V, ScalarLiteral);
48 return saved_type(addr.
getPointer(), ScalarAddress);
54 llvm::StructType::get(V.first->getType(), V.second->getType());
62 return saved_type(addr.getPointer(), ComplexAddress);
68 return saved_type(V.getPointer(), AggregateLiteral,
69 V.getAlignment().getQuantity());
74 return saved_type(addr.getPointer(), AggregateAddress,
75 V.getAlignment().getQuantity());
83 auto alignment = cast<llvm::AllocaInst>(value)->getAlignment();
91 case AggregateLiteral:
93 case AggregateAddress: {
97 case ComplexAddress: {
109 llvm_unreachable(
"bad saved r-value kind");
113 char *EHScopeStack::allocate(
size_t Size) {
115 if (!StartOfBuffer) {
116 unsigned Capacity = 1024;
117 while (Capacity < Size) Capacity *= 2;
118 StartOfBuffer =
new char[Capacity];
119 StartOfData = EndOfBuffer = StartOfBuffer + Capacity;
120 }
else if (static_cast<size_t>(StartOfData - StartOfBuffer) < Size) {
121 unsigned CurrentCapacity = EndOfBuffer - StartOfBuffer;
122 unsigned UsedCapacity = CurrentCapacity - (StartOfData - StartOfBuffer);
124 unsigned NewCapacity = CurrentCapacity;
127 }
while (NewCapacity < UsedCapacity + Size);
129 char *NewStartOfBuffer =
new char[NewCapacity];
130 char *NewEndOfBuffer = NewStartOfBuffer + NewCapacity;
131 char *NewStartOfData = NewEndOfBuffer - UsedCapacity;
132 memcpy(NewStartOfData, StartOfData, UsedCapacity);
133 delete [] StartOfBuffer;
134 StartOfBuffer = NewStartOfBuffer;
135 EndOfBuffer = NewEndOfBuffer;
136 StartOfData = NewStartOfData;
139 assert(StartOfBuffer + Size <= StartOfData);
144 void EHScopeStack::deallocate(
size_t Size) {
162 if (
auto *
cleanup = dyn_cast<EHCleanupScope>(&*
find(si)))
163 if (
cleanup->isLifetimeMarker()) {
164 si =
cleanup->getEnclosingEHScope();
197 InnermostNormalCleanup,
203 if (IsLifetimeMarker)
210 assert(!
empty() &&
"popping exception stack when not empty");
212 assert(isa<EHCleanupScope>(*
begin()));
222 if (!BranchFixups.empty()) {
226 BranchFixups.clear();
243 assert(!
empty() &&
"popping exception stack when not empty");
254 new (buffer)
EHCatchScope(numHandlers, InnermostEHScope);
276 unsigned MinSize = cast<EHCleanupScope>(*it).getFixupDepth();
277 assert(BranchFixups.size() >= MinSize &&
"fixup stack out of order");
279 while (BranchFixups.size() > MinSize &&
280 BranchFixups.back().Destination ==
nullptr)
281 BranchFixups.pop_back();
286 Address active = CreateTempAllocaWithoutCast(
291 setBeforeOutermostConditional(Builder.getFalse(), active);
294 Builder.CreateStore(Builder.getTrue(), active);
302 assert(!cleanup.
hasActiveFlag() &&
"cleanup already has active flag?");
309 void EHScopeStack::Cleanup::anchor() {}
312 llvm::Instruction *beforeInst) {
313 auto store =
new llvm::StoreInst(value, addr.
getPointer(), beforeInst);
318 llvm::Instruction *beforeInst) {
319 auto load =
new llvm::LoadInst(addr.
getPointer(), name, beforeInst);
328 llvm::SwitchInst *Switch,
329 llvm::BasicBlock *CleanupEntry) {
330 llvm::SmallPtrSet<llvm::BasicBlock*, 4> CasesAdded;
366 llvm::BasicBlock *Block) {
369 llvm::Instruction *Term = Block->getTerminator();
370 assert(Term &&
"can't transition block without terminator");
372 if (llvm::BranchInst *Br = dyn_cast<llvm::BranchInst>(Term)) {
373 assert(Br->isUnconditional());
375 "cleanup.dest", Term);
376 llvm::SwitchInst *Switch =
378 Br->eraseFromParent();
381 return cast<llvm::SwitchInst>(Term);
386 assert(Block &&
"resolving a null target block");
387 if (!EHStack.getNumBranchFixups())
return;
389 assert(EHStack.hasNormalCleanups() &&
390 "branch fixups exist with no normal cleanups on stack");
392 llvm::SmallPtrSet<llvm::BasicBlock*, 4> ModifiedOptimisticBlocks;
393 bool ResolvedAny =
false;
395 for (
unsigned I = 0, E = EHStack.getNumBranchFixups(); I != E; ++I) {
410 if (!ModifiedOptimisticBlocks.insert(BranchBB).second)
420 EHStack.popNullFixups();
426 std::initializer_list<llvm::Value **> ValuesToReload) {
429 bool HadBranches =
false;
430 while (EHStack.stable_begin() != Old) {
437 bool FallThroughIsBranchThrough =
440 PopCleanupBlock(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())
463 CreateDefaultAlignTempAlloca(Inst->getType(),
"tmp.exprcleanup");
466 llvm::BasicBlock::iterator InsertBefore;
467 if (
auto *Invoke = dyn_cast<llvm::InvokeInst>(Inst))
468 InsertBefore = Invoke->getNormalDest()->getFirstInsertionPt();
470 InsertBefore = std::next(Inst->getIterator());
474 *ReloadedValue = Builder.CreateLoad(Tmp);
482 std::initializer_list<llvm::Value **> ValuesToReload) {
483 PopCleanupBlocks(Old, ValuesToReload);
486 for (
size_t I = OldLifetimeExtendedSize,
487 E = LifetimeExtendedCleanupStack.size(); I != E; ) {
490 "misaligned cleanup stack entry");
494 LifetimeExtendedCleanupStack[I]);
497 EHStack.pushCopyOfCleanup(Header.
getKind(),
498 &LifetimeExtendedCleanupStack[I],
504 reinterpret_cast<Address &
>(LifetimeExtendedCleanupStack[I]);
505 initFullExprCleanupWithFlag(ActiveFlag);
506 I +=
sizeof(ActiveFlag);
509 LifetimeExtendedCleanupStack.resize(OldLifetimeExtendedSize);
529 llvm::BasicBlock *Entry) {
530 llvm::BasicBlock *Pred = Entry->getSinglePredecessor();
531 if (!Pred)
return Entry;
533 llvm::BranchInst *Br = dyn_cast<llvm::BranchInst>(Pred->getTerminator());
534 if (!Br || Br->isConditional())
return Entry;
535 assert(Br->getSuccessor(0) == Entry);
540 bool WasInsertBlock = CGF.
Builder.GetInsertBlock() == Entry;
541 assert(!WasInsertBlock || CGF.
Builder.GetInsertPoint() == Entry->end());
544 Br->eraseFromParent();
548 Entry->replaceAllUsesWith(Pred);
551 Pred->getInstList().splice(Pred->end(), Entry->getInstList());
554 Entry->eraseFromParent();
557 CGF.
Builder.SetInsertPoint(Pred);
568 llvm::BasicBlock *ContBB =
nullptr;
574 CGF.
Builder.CreateCondBr(IsActive, CleanupBB, ContBB);
579 Fn->
Emit(CGF, flags);
580 assert(CGF.
HaveInsertPoint() &&
"cleanup ended with no insertion point?");
588 llvm::BasicBlock *From,
589 llvm::BasicBlock *To) {
592 llvm::Instruction *Term = Exit->getTerminator();
594 if (llvm::BranchInst *Br = dyn_cast<llvm::BranchInst>(Term)) {
595 assert(Br->isUnconditional() && Br->getSuccessor(0) == From);
596 Br->setSuccessor(0, To);
598 llvm::SwitchInst *Switch = cast<llvm::SwitchInst>(Term);
599 for (
unsigned I = 0, E = Switch->getNumSuccessors(); I != E; ++I)
600 if (Switch->getSuccessor(I) == From)
601 Switch->setSuccessor(I, To);
618 for (llvm::BasicBlock::use_iterator
619 i = entry->use_begin(), e = entry->use_end(); i != e; ) {
623 use.set(unreachableBB);
626 llvm::SwitchInst *si = cast<llvm::SwitchInst>(use.getUser());
627 if (si->getNumCases() == 1 && si->getDefaultDest() == unreachableBB) {
632 llvm::LoadInst *condition = cast<llvm::LoadInst>(si->getCondition());
635 si->eraseFromParent();
639 assert(condition->use_empty());
640 condition->eraseFromParent();
644 assert(entry->use_empty());
652 assert(!EHStack.empty() &&
"cleanup stack is empty!");
653 assert(isa<EHCleanupScope>(*EHStack.begin()) &&
"top not a cleanup!");
655 assert(Scope.
getFixupDepth() <= EHStack.getNumBranchFixups());
670 bool RequiresEHCleanup = (EHEntry !=
nullptr);
677 bool HasFixups = EHStack.getNumBranchFixups() != FixupDepth;
683 llvm::BasicBlock *FallthroughSource = Builder.GetInsertBlock();
684 bool HasFallthrough = (FallthroughSource !=
nullptr && IsActive);
690 bool HasPrebranchedFallthrough =
691 (FallthroughSource && FallthroughSource->getTerminator());
698 FallthroughSource->getTerminator()->getSuccessor(0)
701 bool RequiresNormalCleanup =
false;
703 (HasFixups || HasExistingBranches || HasFallthrough)) {
704 RequiresNormalCleanup =
true;
709 if (Scope.
isNormalCleanup() && HasPrebranchedFallthrough && !IsActive) {
710 llvm::BasicBlock *prebranchDest;
715 if (FallthroughIsBranchThrough) {
724 prebranchDest = createBasicBlock(
"forwarded-prebranch");
725 EmitBlock(prebranchDest);
729 assert(normalEntry && !normalEntry->use_empty());
732 normalEntry, prebranchDest);
736 if (!RequiresNormalCleanup && !RequiresEHCleanup) {
738 EHStack.popCleanup();
739 assert(EHStack.getNumBranchFixups() == 0 ||
740 EHStack.hasNormalCleanups());
750 llvm::AlignedCharArray<EHScopeStack::ScopeStackAlignment, 8 * sizeof(void *)> CleanupBufferStack;
751 std::unique_ptr<char[]> CleanupBufferHeap;
755 if (CleanupSize <=
sizeof(CleanupBufferStack)) {
756 memcpy(CleanupBufferStack.buffer, CleanupSource, CleanupSize);
759 CleanupBufferHeap.reset(
new char[CleanupSize]);
760 memcpy(CleanupBufferHeap.get(), CleanupSource, CleanupSize);
770 if (!RequiresNormalCleanup) {
772 EHStack.popCleanup();
776 if (HasFallthrough && !HasPrebranchedFallthrough &&
777 !HasFixups && !HasExistingBranches) {
780 EHStack.popCleanup();
782 EmitCleanup(*
this, Fn, cleanupFlags, NormalActiveFlag);
792 CGBuilderTy::InsertPoint savedInactiveFallthroughIP;
796 if (HasFallthrough) {
797 if (!HasPrebranchedFallthrough)
798 Builder.CreateStore(Builder.getInt32(0), getNormalCleanupDestSlot());
802 }
else if (FallthroughSource) {
803 assert(!IsActive &&
"source without fallthrough for active cleanup");
804 savedInactiveFallthroughIP = Builder.saveAndClearIP();
810 EmitBlock(NormalEntry);
815 bool HasEnclosingCleanups =
823 llvm::BasicBlock *BranchThroughDest =
nullptr;
825 (FallthroughSource && FallthroughIsBranchThrough) ||
826 (HasFixups && HasEnclosingCleanups)) {
827 assert(HasEnclosingCleanups);
832 llvm::BasicBlock *FallthroughDest =
nullptr;
839 assert(!BranchThroughDest || !IsActive);
842 llvm::Instruction *NormalCleanupDestSlot =
843 cast<llvm::Instruction>(getNormalCleanupDestSlot().getPointer());
844 if (NormalCleanupDestSlot->hasOneUse()) {
845 NormalCleanupDestSlot->user_back()->eraseFromParent();
846 NormalCleanupDestSlot->eraseFromParent();
859 (HasFallthrough && !FallthroughIsBranchThrough) ||
860 (HasFixups && !HasEnclosingCleanups)) {
863 (BranchThroughDest ? BranchThroughDest : getUnreachableBlock());
866 const unsigned SwitchCapacity = 10;
868 llvm::LoadInst *Load =
871 llvm::SwitchInst *Switch =
874 InstsToAppend.push_back(Load);
875 InstsToAppend.push_back(Switch);
878 if (FallthroughSource && !FallthroughIsBranchThrough) {
879 FallthroughDest = createBasicBlock(
"cleanup.cont");
881 Switch->addCase(Builder.getInt32(0), FallthroughDest);
891 if (HasFixups && !HasEnclosingCleanups)
895 assert(BranchThroughDest);
900 EHStack.popCleanup();
901 assert(EHStack.hasNormalCleanups() == HasEnclosingCleanups);
903 EmitCleanup(*
this, Fn, cleanupFlags, NormalActiveFlag);
906 llvm::BasicBlock *NormalExit = Builder.GetInsertBlock();
907 for (
unsigned I = 0, E = InstsToAppend.size(); I != E; ++I)
908 NormalExit->getInstList().push_back(InstsToAppend[I]);
911 for (
unsigned I = FixupDepth, E = EHStack.getNumBranchFixups();
917 getNormalCleanupDestSlot(),
928 if (!HasFallthrough && FallthroughSource) {
933 Builder.restoreIP(savedInactiveFallthroughIP);
938 }
else if (HasFallthrough && FallthroughDest) {
939 assert(!FallthroughIsBranchThrough);
940 EmitBlock(FallthroughDest);
944 }
else if (HasFallthrough) {
949 Builder.ClearInsertionPoint();
956 llvm::BasicBlock *NewNormalEntry =
961 if (NewNormalEntry != NormalEntry && NormalEntry == NormalExit)
962 for (
unsigned I = FixupDepth, E = EHStack.getNumBranchFixups();
964 EHStack.getBranchFixup(I).OptimisticBranchBlock = NewNormalEntry;
968 assert(EHStack.hasNormalCleanups() || EHStack.getNumBranchFixups() == 0);
971 if (RequiresEHCleanup) {
972 CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();
976 llvm::BasicBlock *NextAction = getEHDispatchBlock(EHParent);
981 bool PushedTerminate =
false;
984 llvm::CleanupPadInst *CPI =
nullptr;
990 ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext());
991 CurrentFuncletPad = CPI = Builder.CreateCleanupPad(ParentPad);
996 EHStack.pushTerminate();
997 PushedTerminate =
true;
1002 if (EHActiveFlag.
isValid() || IsActive) {
1004 EmitCleanup(*
this, Fn, cleanupFlags, EHActiveFlag);
1008 Builder.CreateCleanupRet(CPI, NextAction);
1010 Builder.CreateBr(NextAction);
1013 if (PushedTerminate)
1014 EHStack.popTerminate();
1016 Builder.restoreIP(SavedIP);
1027 &&
"stale jump destination");
1031 EHStack.getInnermostActiveNormalCleanup();
1036 if (TopCleanup == EHStack.stable_end() ||
1052 &&
"stale jump destination");
1054 if (!HaveInsertPoint())
1058 llvm::BranchInst *BI = Builder.CreateBr(Dest.
getBlock());
1062 TopCleanup = EHStack.getInnermostActiveNormalCleanup();
1067 if (TopCleanup == EHStack.stable_end() ||
1069 Builder.ClearInsertionPoint();
1082 Builder.ClearInsertionPoint();
1089 llvm::ConstantInt *Index = Builder.getInt32(Dest.
getDestIndex());
1095 cast<EHCleanupScope>(*EHStack.find(TopCleanup));
1123 Builder.ClearInsertionPoint();
1129 if (cast<EHCleanupScope>(*EHStack.
find(C)).getNormalBlock())
1138 if (S.getNormalBlock())
return true;
1139 I = S.getEnclosingNormalCleanup();
1157 if (scope.hasEHBranches())
1160 i = scope.getEnclosingEHScope();
1179 llvm::Instruction *dominatingIP) {
1185 bool isActivatedInConditional =
1188 bool needFlag =
false;
1207 if (!needFlag)
return;
1212 "cleanup.isactive");
1215 assert(dominatingIP &&
"no existing variable and no dominating IP!");
1235 llvm::Instruction *dominatingIP) {
1236 assert(C != EHStack.stable_end() &&
"activating bottom of stack?");
1238 assert(!Scope.isActive() &&
"double activation");
1242 Scope.setActive(
true);
1247 llvm::Instruction *dominatingIP) {
1248 assert(C != EHStack.stable_end() &&
"deactivating bottom of stack?");
1250 assert(Scope.isActive() &&
"double deactivation");
1254 if (C == EHStack.stable_begin() &&
1258 CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();
1260 Builder.restoreIP(SavedIP);
1267 Scope.setActive(
false);
1271 if (!NormalCleanupDest.isValid())
1273 CreateDefaultAlignTempAlloca(Builder.getInt32Ty(),
"cleanup.dest.slot");
1274 return NormalCleanupDest;
const llvm::DataLayout & getDataLayout() const
void pushTerminate()
Push a terminate handler on the stack.
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)
CharUnits - This is an opaque type for sizes expressed in character units.
bool requiresLandingPad() const
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.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
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.
Address CreateStructGEP(Address Addr, unsigned Index, CharUnits Offset, const llvm::Twine &Name="")
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)
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.