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();
291 setBeforeOutermostConditional(Builder.getFalse(), active);
294 Builder.CreateStore(Builder.getTrue(), active);
298 assert(!cleanup.
hasActiveFlag() &&
"cleanup already has active flag?");
305 void EHScopeStack::Cleanup::anchor() {}
308 llvm::Instruction *beforeInst) {
309 auto store =
new llvm::StoreInst(value, addr.
getPointer(), beforeInst);
314 llvm::Instruction *beforeInst) {
315 auto load =
new llvm::LoadInst(addr.
getPointer(), name, beforeInst);
324 llvm::SwitchInst *Switch,
325 llvm::BasicBlock *CleanupEntry) {
326 llvm::SmallPtrSet<llvm::BasicBlock*, 4> CasesAdded;
362 llvm::BasicBlock *Block) {
365 llvm::TerminatorInst *Term = Block->getTerminator();
366 assert(Term &&
"can't transition block without terminator");
368 if (llvm::BranchInst *Br = dyn_cast<llvm::BranchInst>(Term)) {
369 assert(Br->isUnconditional());
371 "cleanup.dest", Term);
372 llvm::SwitchInst *Switch =
374 Br->eraseFromParent();
377 return cast<llvm::SwitchInst>(Term);
382 assert(Block &&
"resolving a null target block");
383 if (!EHStack.getNumBranchFixups())
return;
385 assert(EHStack.hasNormalCleanups() &&
386 "branch fixups exist with no normal cleanups on stack");
388 llvm::SmallPtrSet<llvm::BasicBlock*, 4> ModifiedOptimisticBlocks;
389 bool ResolvedAny =
false;
391 for (
unsigned I = 0, E = EHStack.getNumBranchFixups(); I != E; ++I) {
406 if (!ModifiedOptimisticBlocks.insert(BranchBB).second)
416 EHStack.popNullFixups();
422 std::initializer_list<llvm::Value **> ValuesToReload) {
425 bool HadBranches =
false;
426 while (EHStack.stable_begin() != Old) {
433 bool FallThroughIsBranchThrough =
436 PopCleanupBlock(FallThroughIsBranchThrough);
447 for (
llvm::Value **ReloadedValue : ValuesToReload) {
448 auto *Inst = dyn_cast_or_null<llvm::Instruction>(*ReloadedValue);
454 auto *AI = dyn_cast<llvm::AllocaInst>(Inst);
455 if (AI && AI->isStaticAlloca())
459 CreateDefaultAlignTempAlloca(Inst->getType(),
"tmp.exprcleanup");
462 llvm::BasicBlock::iterator InsertBefore;
463 if (
auto *Invoke = dyn_cast<llvm::InvokeInst>(Inst))
464 InsertBefore = Invoke->getNormalDest()->getFirstInsertionPt();
466 InsertBefore = std::next(Inst->getIterator());
470 *ReloadedValue = Builder.CreateLoad(Tmp);
478 std::initializer_list<llvm::Value **> ValuesToReload) {
479 PopCleanupBlocks(Old, ValuesToReload);
482 for (
size_t I = OldLifetimeExtendedSize,
483 E = LifetimeExtendedCleanupStack.size(); I != E; ) {
486 "misaligned cleanup stack entry");
490 LifetimeExtendedCleanupStack[I]);
493 EHStack.pushCopyOfCleanup(Header.
getKind(),
494 &LifetimeExtendedCleanupStack[I],
498 LifetimeExtendedCleanupStack.resize(OldLifetimeExtendedSize);
518 llvm::BasicBlock *Entry) {
519 llvm::BasicBlock *Pred = Entry->getSinglePredecessor();
520 if (!Pred)
return Entry;
522 llvm::BranchInst *Br = dyn_cast<llvm::BranchInst>(Pred->getTerminator());
523 if (!Br || Br->isConditional())
return Entry;
524 assert(Br->getSuccessor(0) == Entry);
529 bool WasInsertBlock = CGF.
Builder.GetInsertBlock() == Entry;
530 assert(!WasInsertBlock || CGF.
Builder.GetInsertPoint() == Entry->end());
533 Br->eraseFromParent();
537 Entry->replaceAllUsesWith(Pred);
540 Pred->getInstList().splice(Pred->end(), Entry->getInstList());
543 Entry->eraseFromParent();
546 CGF.
Builder.SetInsertPoint(Pred);
557 llvm::BasicBlock *ContBB =
nullptr;
563 CGF.
Builder.CreateCondBr(IsActive, CleanupBB, ContBB);
568 Fn->
Emit(CGF, flags);
569 assert(CGF.
HaveInsertPoint() &&
"cleanup ended with no insertion point?");
577 llvm::BasicBlock *From,
578 llvm::BasicBlock *To) {
581 llvm::TerminatorInst *Term = Exit->getTerminator();
583 if (llvm::BranchInst *Br = dyn_cast<llvm::BranchInst>(Term)) {
584 assert(Br->isUnconditional() && Br->getSuccessor(0) == From);
585 Br->setSuccessor(0, To);
587 llvm::SwitchInst *Switch = cast<llvm::SwitchInst>(Term);
588 for (
unsigned I = 0, E = Switch->getNumSuccessors(); I != E; ++I)
589 if (Switch->getSuccessor(I) == From)
590 Switch->setSuccessor(I, To);
607 for (llvm::BasicBlock::use_iterator
608 i = entry->use_begin(), e = entry->use_end(); i != e; ) {
612 use.set(unreachableBB);
615 llvm::SwitchInst *si = cast<llvm::SwitchInst>(use.getUser());
616 if (si->getNumCases() == 1 && si->getDefaultDest() == unreachableBB) {
621 llvm::LoadInst *condition = cast<llvm::LoadInst>(si->getCondition());
624 si->eraseFromParent();
628 assert(condition->use_empty());
629 condition->eraseFromParent();
633 assert(entry->use_empty());
641 assert(!EHStack.empty() &&
"cleanup stack is empty!");
642 assert(isa<EHCleanupScope>(*EHStack.begin()) &&
"top not a cleanup!");
644 assert(Scope.
getFixupDepth() <= EHStack.getNumBranchFixups());
659 bool RequiresEHCleanup = (EHEntry !=
nullptr);
666 bool HasFixups = EHStack.getNumBranchFixups() != FixupDepth;
672 llvm::BasicBlock *FallthroughSource = Builder.GetInsertBlock();
673 bool HasFallthrough = (FallthroughSource !=
nullptr && IsActive);
679 bool HasPrebranchedFallthrough =
680 (FallthroughSource && FallthroughSource->getTerminator());
687 FallthroughSource->getTerminator()->getSuccessor(0)
690 bool RequiresNormalCleanup =
false;
692 (HasFixups || HasExistingBranches || HasFallthrough)) {
693 RequiresNormalCleanup =
true;
698 if (Scope.
isNormalCleanup() && HasPrebranchedFallthrough && !IsActive) {
699 llvm::BasicBlock *prebranchDest;
704 if (FallthroughIsBranchThrough) {
713 prebranchDest = createBasicBlock(
"forwarded-prebranch");
714 EmitBlock(prebranchDest);
718 assert(normalEntry && !normalEntry->use_empty());
721 normalEntry, prebranchDest);
725 if (!RequiresNormalCleanup && !RequiresEHCleanup) {
727 EHStack.popCleanup();
728 assert(EHStack.getNumBranchFixups() == 0 ||
729 EHStack.hasNormalCleanups());
739 llvm::AlignedCharArray<EHScopeStack::ScopeStackAlignment, 8 * sizeof(void *)> CleanupBufferStack;
740 std::unique_ptr<char[]> CleanupBufferHeap;
744 if (CleanupSize <=
sizeof(CleanupBufferStack)) {
745 memcpy(CleanupBufferStack.buffer, CleanupSource, CleanupSize);
748 CleanupBufferHeap.reset(
new char[CleanupSize]);
749 memcpy(CleanupBufferHeap.get(), CleanupSource, CleanupSize);
759 if (!RequiresNormalCleanup) {
761 EHStack.popCleanup();
765 if (HasFallthrough && !HasPrebranchedFallthrough &&
766 !HasFixups && !HasExistingBranches) {
769 EHStack.popCleanup();
771 EmitCleanup(*
this, Fn, cleanupFlags, NormalActiveFlag);
781 CGBuilderTy::InsertPoint savedInactiveFallthroughIP;
785 if (HasFallthrough) {
786 if (!HasPrebranchedFallthrough)
787 Builder.CreateStore(Builder.getInt32(0), getNormalCleanupDestSlot());
791 }
else if (FallthroughSource) {
792 assert(!IsActive &&
"source without fallthrough for active cleanup");
793 savedInactiveFallthroughIP = Builder.saveAndClearIP();
799 EmitBlock(NormalEntry);
804 bool HasEnclosingCleanups =
812 llvm::BasicBlock *BranchThroughDest =
nullptr;
814 (FallthroughSource && FallthroughIsBranchThrough) ||
815 (HasFixups && HasEnclosingCleanups)) {
816 assert(HasEnclosingCleanups);
821 llvm::BasicBlock *FallthroughDest =
nullptr;
828 assert(!BranchThroughDest || !IsActive);
831 llvm::Instruction *NormalCleanupDestSlot =
832 cast<llvm::Instruction>(getNormalCleanupDestSlot().getPointer());
833 if (NormalCleanupDestSlot->hasOneUse()) {
834 NormalCleanupDestSlot->user_back()->eraseFromParent();
835 NormalCleanupDestSlot->eraseFromParent();
836 NormalCleanupDest =
nullptr;
848 (HasFallthrough && !FallthroughIsBranchThrough) ||
849 (HasFixups && !HasEnclosingCleanups)) {
852 (BranchThroughDest ? BranchThroughDest : getUnreachableBlock());
855 const unsigned SwitchCapacity = 10;
857 llvm::LoadInst *Load =
860 llvm::SwitchInst *Switch =
863 InstsToAppend.push_back(Load);
864 InstsToAppend.push_back(Switch);
867 if (FallthroughSource && !FallthroughIsBranchThrough) {
868 FallthroughDest = createBasicBlock(
"cleanup.cont");
870 Switch->addCase(Builder.getInt32(0), FallthroughDest);
880 if (HasFixups && !HasEnclosingCleanups)
884 assert(BranchThroughDest);
889 EHStack.popCleanup();
890 assert(EHStack.hasNormalCleanups() == HasEnclosingCleanups);
892 EmitCleanup(*
this, Fn, cleanupFlags, NormalActiveFlag);
895 llvm::BasicBlock *NormalExit = Builder.GetInsertBlock();
896 for (
unsigned I = 0, E = InstsToAppend.size(); I != E; ++I)
897 NormalExit->getInstList().push_back(InstsToAppend[I]);
900 for (
unsigned I = FixupDepth, E = EHStack.getNumBranchFixups();
906 getNormalCleanupDestSlot(),
917 if (!HasFallthrough && FallthroughSource) {
922 Builder.restoreIP(savedInactiveFallthroughIP);
927 }
else if (HasFallthrough && FallthroughDest) {
928 assert(!FallthroughIsBranchThrough);
929 EmitBlock(FallthroughDest);
933 }
else if (HasFallthrough) {
938 Builder.ClearInsertionPoint();
945 llvm::BasicBlock *NewNormalEntry =
950 if (NewNormalEntry != NormalEntry && NormalEntry == NormalExit)
951 for (
unsigned I = FixupDepth, E = EHStack.getNumBranchFixups();
953 EHStack.getBranchFixup(I).OptimisticBranchBlock = NewNormalEntry;
957 assert(EHStack.hasNormalCleanups() || EHStack.getNumBranchFixups() == 0);
960 if (RequiresEHCleanup) {
961 CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();
965 llvm::BasicBlock *NextAction = getEHDispatchBlock(EHParent);
970 bool PushedTerminate =
false;
973 llvm::CleanupPadInst *CPI =
nullptr;
975 EHStack.pushTerminate();
976 PushedTerminate =
true;
980 ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext());
981 CurrentFuncletPad = CPI = Builder.CreateCleanupPad(ParentPad);
986 if (EHActiveFlag.
isValid() || IsActive) {
988 EmitCleanup(*
this, Fn, cleanupFlags, EHActiveFlag);
992 Builder.CreateCleanupRet(CPI, NextAction);
994 Builder.CreateBr(NextAction);
998 EHStack.popTerminate();
1000 Builder.restoreIP(SavedIP);
1011 &&
"stale jump destination");
1015 EHStack.getInnermostActiveNormalCleanup();
1020 if (TopCleanup == EHStack.stable_end() ||
1036 &&
"stale jump destination");
1038 if (!HaveInsertPoint())
1042 llvm::BranchInst *BI = Builder.CreateBr(Dest.
getBlock());
1046 TopCleanup = EHStack.getInnermostActiveNormalCleanup();
1051 if (TopCleanup == EHStack.stable_end() ||
1053 Builder.ClearInsertionPoint();
1066 Builder.ClearInsertionPoint();
1073 llvm::ConstantInt *Index = Builder.getInt32(Dest.
getDestIndex());
1079 cast<EHCleanupScope>(*EHStack.find(TopCleanup));
1107 Builder.ClearInsertionPoint();
1113 if (cast<EHCleanupScope>(*EHStack.
find(C)).getNormalBlock())
1122 if (S.getNormalBlock())
return true;
1123 I = S.getEnclosingNormalCleanup();
1141 if (scope.hasEHBranches())
1144 i = scope.getEnclosingEHScope();
1163 llvm::Instruction *dominatingIP) {
1169 bool isActivatedInConditional =
1172 bool needFlag =
false;
1191 if (!needFlag)
return;
1196 "cleanup.isactive");
1199 assert(dominatingIP &&
"no existing variable and no dominating IP!");
1219 llvm::Instruction *dominatingIP) {
1220 assert(C != EHStack.stable_end() &&
"activating bottom of stack?");
1222 assert(!Scope.isActive() &&
"double activation");
1226 Scope.setActive(
true);
1231 llvm::Instruction *dominatingIP) {
1232 assert(C != EHStack.stable_end() &&
"deactivating bottom of stack?");
1234 assert(Scope.isActive() &&
"double deactivation");
1237 if (C == EHStack.stable_begin()) {
1240 CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();
1242 Builder.restoreIP(SavedIP);
1249 Scope.setActive(
false);
1253 if (!NormalCleanupDest)
1255 CreateTempAlloca(Builder.getInt32Ty(),
"cleanup.dest.slot");
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.
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.
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.
void initFullExprCleanup()
Set up the last cleaup that was pushed as a conditional full-expression cleanup.
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...
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...
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()
llvm::AllocaInst * NormalCleanupDest
i32s containing the indexes of the cleanup destinations.
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()
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
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.