clang 24.0.0git
CGCleanup.h
Go to the documentation of this file.
1//===-- CGCleanup.h - Classes for cleanups IR generation --------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// These classes support the generation of LLVM IR for cleanups.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_CODEGEN_CGCLEANUP_H
14#define LLVM_CLANG_LIB_CODEGEN_CGCLEANUP_H
15
16#include "EHScopeStack.h"
17
18#include "Address.h"
20#include "llvm/ADT/STLExtras.h"
21#include "llvm/ADT/SetVector.h"
22#include "llvm/ADT/SmallPtrSet.h"
23#include "llvm/ADT/SmallVector.h"
24#include "llvm/IR/Instruction.h"
25
26namespace llvm {
27class BasicBlock;
28class Value;
29class ConstantInt;
30}
31
32namespace clang {
33class FunctionDecl;
34namespace CodeGen {
35class CodeGenModule;
36class CodeGenFunction;
37
38/// The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the
39/// type of a catch handler, so we use this wrapper.
41 llvm::Constant *RTTI;
42 unsigned Flags;
43};
44
45/// A protected scope for zero-cost EH handling.
46class EHScope {
47public:
49
50private:
51 llvm::BasicBlock *CachedLandingPad;
52 llvm::BasicBlock *CachedEHDispatchBlock;
53
54 EHScopeStack::stable_iterator EnclosingEHScope;
55
56 class CommonBitFields {
57 friend class EHScope;
58 LLVM_PREFERRED_TYPE(Kind)
59 unsigned Kind : 3;
60 };
61 enum { NumCommonBits = 3 };
62
63protected:
65 friend class EHCatchScope;
66 unsigned : NumCommonBits;
67
68 unsigned NumHandlers : 32 - NumCommonBits;
69 };
70
72 friend class EHCleanupScope;
73 unsigned : NumCommonBits;
74
75 /// Whether this cleanup needs to be run along normal edges.
76 LLVM_PREFERRED_TYPE(bool)
77 unsigned IsNormalCleanup : 1;
78
79 /// Whether this cleanup needs to be run along exception edges.
80 LLVM_PREFERRED_TYPE(bool)
81 unsigned IsEHCleanup : 1;
82
83 /// Whether this cleanup is currently active.
84 LLVM_PREFERRED_TYPE(bool)
85 unsigned IsActive : 1;
86
87 /// Whether this cleanup is a lifetime marker
88 LLVM_PREFERRED_TYPE(bool)
89 unsigned IsLifetimeMarker : 1;
90
91 /// Whether this cleanup is a fake use
92 LLVM_PREFERRED_TYPE(bool)
93 unsigned IsFakeUse : 1;
94
95 /// Whether the normal cleanup should test the activation flag.
96 LLVM_PREFERRED_TYPE(bool)
97 unsigned TestFlagInNormalCleanup : 1;
98
99 /// Whether the EH cleanup should test the activation flag.
100 LLVM_PREFERRED_TYPE(bool)
101 unsigned TestFlagInEHCleanup : 1;
102
103 LLVM_PREFERRED_TYPE(bool)
104 unsigned IsSEHFinallyCleanup : 1;
105
106 LLVM_PREFERRED_TYPE(bool)
107 unsigned IsStackRestore : 1;
108
109 /// The amount of extra storage needed by the Cleanup.
110 /// Always a multiple of the scope-stack alignment.
111 unsigned CleanupSize : 12;
112 };
113
115 friend class EHFilterScope;
116 unsigned : NumCommonBits;
117
118 unsigned NumFilters : 32 - NumCommonBits;
119 };
120
121 union {
122 CommonBitFields CommonBits;
126 };
127
128public:
130 : CachedLandingPad(nullptr), CachedEHDispatchBlock(nullptr),
131 EnclosingEHScope(enclosingEHScope) {
132 CommonBits.Kind = kind;
133 }
134
135 Kind getKind() const { return static_cast<Kind>(CommonBits.Kind); }
136
137 llvm::BasicBlock *getCachedLandingPad() const {
138 return CachedLandingPad;
139 }
140
141 void setCachedLandingPad(llvm::BasicBlock *block) {
142 CachedLandingPad = block;
143 }
144
145 llvm::BasicBlock *getCachedEHDispatchBlock() const {
146 return CachedEHDispatchBlock;
147 }
148
149 void setCachedEHDispatchBlock(llvm::BasicBlock *block) {
150 CachedEHDispatchBlock = block;
151 }
152
153 bool hasEHBranches() const {
154 if (llvm::BasicBlock *block = getCachedEHDispatchBlock())
155 return !block->use_empty();
156 return false;
157 }
158
160 return EnclosingEHScope;
161 }
162};
163
164/// A scope which attempts to handle some, possibly all, types of
165/// exceptions.
166///
167/// Objective C \@finally blocks are represented using a cleanup scope
168/// after the catch scope.
169class EHCatchScope : public EHScope {
170 // In effect, we have a flexible array member
171 // Handler Handlers[0];
172 // But that's only standard in C99, not C++, so we have to do
173 // annoying pointer arithmetic instead.
174
175public:
176 struct Handler {
177 /// A type info value, or null (C++ null, not an LLVM null pointer)
178 /// for a catch-all.
180
181 /// The catch handler for this type.
182 llvm::BasicBlock *Block;
183
184 bool isCatchAll() const { return Type.RTTI == nullptr; }
185 };
186
187private:
188 friend class EHScopeStack;
189
190 Handler *getHandlers() {
191 return reinterpret_cast<Handler*>(this+1);
192 }
193
194 const Handler *getHandlers() const {
195 return reinterpret_cast<const Handler*>(this+1);
196 }
197
198public:
199 static size_t getSizeForNumHandlers(unsigned N) {
200 return sizeof(EHCatchScope) + N * sizeof(Handler);
201 }
202
203 EHCatchScope(unsigned numHandlers,
204 EHScopeStack::stable_iterator enclosingEHScope)
205 : EHScope(Catch, enclosingEHScope) {
206 CatchBits.NumHandlers = numHandlers;
207 assert(CatchBits.NumHandlers == numHandlers && "NumHandlers overflow?");
208 }
209
210 unsigned getNumHandlers() const {
211 return CatchBits.NumHandlers;
212 }
213
214 void setCatchAllHandler(unsigned I, llvm::BasicBlock *Block) {
215 setHandler(I, CatchTypeInfo{nullptr, 0}, Block);
216 }
217
218 void setHandler(unsigned I, llvm::Constant *Type, llvm::BasicBlock *Block) {
219 assert(I < getNumHandlers());
220 getHandlers()[I].Type = CatchTypeInfo{Type, 0};
221 getHandlers()[I].Block = Block;
222 }
223
224 void setHandler(unsigned I, CatchTypeInfo Type, llvm::BasicBlock *Block) {
225 assert(I < getNumHandlers());
226 getHandlers()[I].Type = Type;
227 getHandlers()[I].Block = Block;
228 }
229
230 const Handler &getHandler(unsigned I) const {
231 assert(I < getNumHandlers());
232 return getHandlers()[I];
233 }
234
235 // Clear all handler blocks.
236 // FIXME: it's better to always call clearHandlerBlocks in DTOR and have a
237 // 'takeHandler' or some such function which removes ownership from the
238 // EHCatchScope object if the handlers should live longer than EHCatchScope.
240 for (unsigned I = 0, N = getNumHandlers(); I != N; ++I)
241 delete getHandler(I).Block;
242 }
243
244 typedef const Handler *iterator;
245 iterator begin() const { return getHandlers(); }
246 iterator end() const { return getHandlers() + getNumHandlers(); }
247
248 static bool classof(const EHScope *Scope) {
249 return Scope->getKind() == Catch;
250 }
251};
252
253/// A cleanup scope which generates the cleanup blocks lazily.
254class alignas(8) EHCleanupScope : public EHScope {
255 /// The nearest normal cleanup scope enclosing this one.
256 EHScopeStack::stable_iterator EnclosingNormal;
257
258 /// The nearest EH scope enclosing this one.
260
261 /// The dual entry/exit block along the normal edge. This is lazily
262 /// created if needed before the cleanup is popped.
263 llvm::BasicBlock *NormalBlock;
264
265 /// An optional i1 variable indicating whether this cleanup has been
266 /// activated yet.
267 Address ActiveFlag;
268
269 /// Extra information required for cleanups that have resolved
270 /// branches through them. This has to be allocated on the side
271 /// because everything on the cleanup stack has be trivially
272 /// movable.
273 struct ExtInfo {
274 /// The destinations of normal branch-afters and branch-throughs.
276
277 /// Normal branch-afters.
279 BranchAfters;
280 };
281 mutable struct ExtInfo *ExtInfo;
282
283 /// Erases auxillary allocas and their usages for an unused cleanup.
284 /// Cleanups should mark these allocas as 'used' if the cleanup is
285 /// emitted, otherwise these instructions would be erased.
286 struct AuxillaryAllocas {
288 bool used = false;
289
290 // Records a potentially unused instruction to be erased later.
291 void Add(llvm::AllocaInst *Alloca) { AuxAllocas.push_back(Alloca); }
292
293 // Mark all recorded instructions as used. These will not be erased later.
294 void MarkUsed() {
295 used = true;
296 AuxAllocas.clear();
297 }
298
299 ~AuxillaryAllocas() {
300 if (used)
301 return;
302 llvm::SetVector<llvm::Instruction *> Uses;
303 for (auto *Inst : llvm::reverse(AuxAllocas))
304 CollectUses(Inst, Uses);
305 // Delete uses in the reverse order of insertion.
306 for (auto *I : llvm::reverse(Uses))
307 I->eraseFromParent();
308 }
309
310 private:
311 void CollectUses(llvm::Instruction *I,
312 llvm::SetVector<llvm::Instruction *> &Uses) {
313 if (!I || !Uses.insert(I))
314 return;
315 for (auto *User : I->users())
316 CollectUses(cast<llvm::Instruction>(User), Uses);
317 }
318 };
319 mutable struct AuxillaryAllocas *AuxAllocas;
320
321 AuxillaryAllocas &getAuxillaryAllocas() {
322 if (!AuxAllocas) {
323 AuxAllocas = new struct AuxillaryAllocas();
324 }
325 return *AuxAllocas;
326 }
327
328 /// The number of fixups required by enclosing scopes (not including
329 /// this one). If this is the top cleanup scope, all the fixups
330 /// from this index onwards belong to this scope.
331 unsigned FixupDepth;
332
333 struct ExtInfo &getExtInfo() {
334 if (!ExtInfo) ExtInfo = new struct ExtInfo();
335 return *ExtInfo;
336 }
337
338 const struct ExtInfo &getExtInfo() const {
339 if (!ExtInfo) ExtInfo = new struct ExtInfo();
340 return *ExtInfo;
341 }
342
343public:
344 /// Gets the size required for a lazy cleanup scope with the given
345 /// cleanup-data requirements.
346 static size_t getSizeForCleanupSize(size_t Size) {
347 return sizeof(EHCleanupScope) + Size;
348 }
349
350 size_t getAllocatedSize() const {
351 return sizeof(EHCleanupScope) + CleanupBits.CleanupSize;
352 }
353
354 EHCleanupScope(bool isNormal, bool isEH, unsigned cleanupSize,
355 unsigned fixupDepth,
356 EHScopeStack::stable_iterator enclosingNormal,
358 : EHScope(EHScope::Cleanup, enclosingEH),
359 EnclosingNormal(enclosingNormal), NormalBlock(nullptr),
360 ActiveFlag(Address::invalid()), ExtInfo(nullptr), AuxAllocas(nullptr),
361 FixupDepth(fixupDepth) {
362 CleanupBits.IsNormalCleanup = isNormal;
363 CleanupBits.IsEHCleanup = isEH;
364 CleanupBits.IsActive = true;
365 CleanupBits.IsLifetimeMarker = false;
366 CleanupBits.IsFakeUse = false;
367 CleanupBits.IsSEHFinallyCleanup = false;
368 CleanupBits.IsStackRestore = false;
369 CleanupBits.TestFlagInNormalCleanup = false;
370 CleanupBits.TestFlagInEHCleanup = false;
371 CleanupBits.CleanupSize = cleanupSize;
372
373 assert(CleanupBits.CleanupSize == cleanupSize && "cleanup size overflow");
374 }
375
376 void Destroy() {
377 if (AuxAllocas)
378 delete AuxAllocas;
379 delete ExtInfo;
380 }
382 for (auto *Alloca : Allocas)
383 getAuxillaryAllocas().Add(Alloca);
384 }
385 void MarkEmitted() { getAuxillaryAllocas().MarkUsed(); }
386 // Objects of EHCleanupScope are not destructed. Use Destroy().
387 ~EHCleanupScope() = delete;
388
389 bool isNormalCleanup() const { return CleanupBits.IsNormalCleanup; }
390 llvm::BasicBlock *getNormalBlock() const { return NormalBlock; }
391 void setNormalBlock(llvm::BasicBlock *BB) { NormalBlock = BB; }
392
393 bool isEHCleanup() const { return CleanupBits.IsEHCleanup; }
394
395 bool isActive() const { return CleanupBits.IsActive; }
396 void setActive(bool A) { CleanupBits.IsActive = A; }
397
398 bool isLifetimeMarker() const { return CleanupBits.IsLifetimeMarker; }
399 void setLifetimeMarker() { CleanupBits.IsLifetimeMarker = true; }
400
401 bool isStackRestore() const { return CleanupBits.IsStackRestore; }
402 void setStackRestore() { CleanupBits.IsStackRestore = true; }
403
405 return isLifetimeMarker() || isStackRestore();
406 }
407
408 bool isFakeUse() const { return CleanupBits.IsFakeUse; }
409 void setFakeUse() { CleanupBits.IsFakeUse = true; }
410
411 bool isSEHFinallyCleanup() const { return CleanupBits.IsSEHFinallyCleanup; }
412 void setSEHFinallyCleanup() { CleanupBits.IsSEHFinallyCleanup = true; }
413
414 bool hasActiveFlag() const { return ActiveFlag.isValid(); }
416 return ActiveFlag;
417 }
419 assert(Var.getAlignment().isOne());
420 ActiveFlag = Var;
421 }
422
424 CleanupBits.TestFlagInNormalCleanup = true;
425 }
427 return CleanupBits.TestFlagInNormalCleanup;
428 }
429
431 CleanupBits.TestFlagInEHCleanup = true;
432 }
434 return CleanupBits.TestFlagInEHCleanup;
435 }
436
437 unsigned getFixupDepth() const { return FixupDepth; }
439 return EnclosingNormal;
440 }
441
442 size_t getCleanupSize() const { return CleanupBits.CleanupSize; }
443 void *getCleanupBuffer() { return this + 1; }
444
445 EHScopeStack::Cleanup *getCleanup() {
446 return reinterpret_cast<EHScopeStack::Cleanup*>(getCleanupBuffer());
447 }
448
449 /// True if this cleanup scope has any branch-afters or branch-throughs.
450 bool hasBranches() const { return ExtInfo && !ExtInfo->Branches.empty(); }
451
452 /// Add a branch-after to this cleanup scope. A branch-after is a
453 /// branch from a point protected by this (normal) cleanup to a
454 /// point in the normal cleanup scope immediately containing it.
455 /// For example,
456 /// for (;;) { A a; break; }
457 /// contains a branch-after.
458 ///
459 /// Branch-afters each have their own destination out of the
460 /// cleanup, guaranteed distinct from anything else threaded through
461 /// it. Therefore branch-afters usually force a switch after the
462 /// cleanup.
463 void addBranchAfter(llvm::ConstantInt *Index,
464 llvm::BasicBlock *Block) {
465 struct ExtInfo &ExtInfo = getExtInfo();
466 if (ExtInfo.Branches.insert(Block).second)
467 ExtInfo.BranchAfters.push_back(std::make_pair(Block, Index));
468 }
469
470 /// Return the number of unique branch-afters on this scope.
471 unsigned getNumBranchAfters() const {
472 return ExtInfo ? ExtInfo->BranchAfters.size() : 0;
473 }
474
475 llvm::BasicBlock *getBranchAfterBlock(unsigned I) const {
476 assert(I < getNumBranchAfters());
477 return ExtInfo->BranchAfters[I].first;
478 }
479
480 llvm::ConstantInt *getBranchAfterIndex(unsigned I) const {
481 assert(I < getNumBranchAfters());
482 return ExtInfo->BranchAfters[I].second;
483 }
484
485 /// Add a branch-through to this cleanup scope. A branch-through is
486 /// a branch from a scope protected by this (normal) cleanup to an
487 /// enclosing scope other than the immediately-enclosing normal
488 /// cleanup scope.
489 ///
490 /// In the following example, the branch through B's scope is a
491 /// branch-through, while the branch through A's scope is a
492 /// branch-after:
493 /// for (;;) { A a; B b; break; }
494 ///
495 /// All branch-throughs have a common destination out of the
496 /// cleanup, one possibly shared with the fall-through. Therefore
497 /// branch-throughs usually don't force a switch after the cleanup.
498 ///
499 /// \return true if the branch-through was new to this scope
500 bool addBranchThrough(llvm::BasicBlock *Block) {
501 return getExtInfo().Branches.insert(Block).second;
502 }
503
504 /// Determines if this cleanup scope has any branch throughs.
505 bool hasBranchThroughs() const {
506 if (!ExtInfo) return false;
507 return (ExtInfo->BranchAfters.size() != ExtInfo->Branches.size());
508 }
509
510 static bool classof(const EHScope *Scope) {
511 return (Scope->getKind() == Cleanup);
512 }
513};
514// NOTE: there's a bunch of different data classes tacked on after an
515// EHCleanupScope. It is asserted (in EHScopeStack::pushCleanup*) that
516// they don't require greater alignment than ScopeStackAlignment. So,
517// EHCleanupScope ought to have alignment equal to that -- not more
518// (would be misaligned by the stack allocator), and not less (would
519// break the appended classes).
520static_assert(alignof(EHCleanupScope) == EHScopeStack::ScopeStackAlignment,
521 "EHCleanupScope expected alignment");
522
523/// An exceptions scope which filters exceptions thrown through it.
524/// Only exceptions matching the filter types will be permitted to be
525/// thrown.
526///
527/// This is used to implement C++ exception specifications.
528class EHFilterScope : public EHScope {
529 // Essentially ends in a flexible array member:
530 // llvm::Value *FilterTypes[0];
531
532 llvm::Value **getFilters() {
533 return reinterpret_cast<llvm::Value**>(this+1);
534 }
535
536 llvm::Value * const *getFilters() const {
537 return reinterpret_cast<llvm::Value* const *>(this+1);
538 }
539
540public:
541 EHFilterScope(unsigned numFilters)
542 : EHScope(Filter, EHScopeStack::stable_end()) {
543 FilterBits.NumFilters = numFilters;
544 assert(FilterBits.NumFilters == numFilters && "NumFilters overflow");
545 }
546
547 static size_t getSizeForNumFilters(unsigned numFilters) {
548 return sizeof(EHFilterScope) + numFilters * sizeof(llvm::Value*);
549 }
550
551 unsigned getNumFilters() const { return FilterBits.NumFilters; }
552
553 void setFilter(unsigned i, llvm::Value *filterValue) {
554 assert(i < getNumFilters());
555 getFilters()[i] = filterValue;
556 }
557
558 llvm::Value *getFilter(unsigned i) const {
559 assert(i < getNumFilters());
560 return getFilters()[i];
561 }
562
563 static bool classof(const EHScope *scope) {
564 return scope->getKind() == Filter;
565 }
566};
567
568/// An exceptions scope which calls std::terminate if any exception
569/// reaches it.
570class EHTerminateScope : public EHScope {
571public:
573 : EHScope(Terminate, enclosingEHScope) {}
574 static size_t getSize() { return sizeof(EHTerminateScope); }
575
576 static bool classof(const EHScope *scope) {
577 return scope->getKind() == Terminate;
578 }
579};
580
581/// A non-stable pointer into the scope stack.
583 char *Ptr;
584
585 friend class EHScopeStack;
586 explicit iterator(char *Ptr) : Ptr(Ptr) {}
587
588public:
589 iterator() : Ptr(nullptr) {}
590
591 EHScope *get() const {
592 return reinterpret_cast<EHScope*>(Ptr);
593 }
594
595 EHScope *operator->() const { return get(); }
596 EHScope &operator*() const { return *get(); }
597
598 iterator &operator++() {
599 size_t Size;
600 switch (get()->getKind()) {
601 case EHScope::Catch:
603 static_cast<const EHCatchScope *>(get())->getNumHandlers());
604 break;
605
606 case EHScope::Filter:
608 static_cast<const EHFilterScope *>(get())->getNumFilters());
609 break;
610
611 case EHScope::Cleanup:
612 Size = static_cast<const EHCleanupScope *>(get())->getAllocatedSize();
613 break;
614
617 break;
618 }
619 Ptr += llvm::alignTo(Size, ScopeStackAlignment);
620 return *this;
621 }
622
623 iterator next() {
624 iterator copy = *this;
625 ++copy;
626 return copy;
627 }
628
629 iterator operator++(int) {
630 iterator copy = *this;
631 operator++();
632 return copy;
633 }
634
635 bool encloses(iterator other) const { return Ptr >= other.Ptr; }
636 bool strictlyEncloses(iterator other) const { return Ptr > other.Ptr; }
637
638 bool operator==(iterator other) const { return Ptr == other.Ptr; }
639 bool operator!=(iterator other) const { return Ptr != other.Ptr; }
640};
641
643 return iterator(StartOfData);
644}
645
647 return iterator(EndOfBuffer);
648}
649
651 assert(!empty() && "popping exception stack when not empty");
652
654 InnermostEHScope = scope.getEnclosingEHScope();
656}
657
659 assert(!empty() && "popping exception stack when not empty");
660
662 InnermostEHScope = scope.getEnclosingEHScope();
663 deallocate(EHTerminateScope::getSize());
664}
665
667 assert(sp.isValid() && "finding invalid savepoint");
668 assert(sp.Size <= stable_begin().Size && "finding savepoint after pop");
669 return iterator(EndOfBuffer - sp.Size);
670}
671
674 assert(StartOfData <= ir.Ptr && ir.Ptr <= EndOfBuffer);
675 return stable_iterator(EndOfBuffer - ir.Ptr);
676}
677
679
680/// Selects the personality function to use for \p FD, or for the translation
681/// unit as a whole when \p FD is null.
683 const FunctionDecl *FD);
684
685/// Selects the personality function to use for the function currently being
686/// emitted.
688}
689}
690
691#endif
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 kind
bool isOne() const
Test whether the quantity equals one.
Definition CharUnits.h:104
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
Definition Address.h:128
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-function state that is used while generating LLVM code.
A scope which attempts to handle some, possibly all, types of exceptions.
Definition CGCleanup.h:169
EHCatchScope(unsigned numHandlers, EHScopeStack::stable_iterator enclosingEHScope)
Definition CGCleanup.h:203
const Handler & getHandler(unsigned I) const
Definition CGCleanup.h:230
void setHandler(unsigned I, llvm::Constant *Type, llvm::BasicBlock *Block)
Definition CGCleanup.h:218
static size_t getSizeForNumHandlers(unsigned N)
Definition CGCleanup.h:199
void setHandler(unsigned I, CatchTypeInfo Type, llvm::BasicBlock *Block)
Definition CGCleanup.h:224
void setCatchAllHandler(unsigned I, llvm::BasicBlock *Block)
Definition CGCleanup.h:214
static bool classof(const EHScope *Scope)
Definition CGCleanup.h:248
unsigned getNumHandlers() const
Definition CGCleanup.h:210
A cleanup scope which generates the cleanup blocks lazily.
Definition CGCleanup.h:254
bool shouldTestFlagInEHCleanup() const
Definition CGCleanup.h:433
Address getActiveFlag() const
Definition CGCleanup.h:415
EHScopeStack::stable_iterator getEnclosingNormalCleanup() const
Definition CGCleanup.h:438
size_t getAllocatedSize() const
Definition CGCleanup.h:350
void setNormalBlock(llvm::BasicBlock *BB)
Definition CGCleanup.h:391
llvm::ConstantInt * getBranchAfterIndex(unsigned I) const
Definition CGCleanup.h:480
bool shouldTestFlagInNormalCleanup() const
Definition CGCleanup.h:426
bool isRedundantBeforeReturn() const
Definition CGCleanup.h:404
bool addBranchThrough(llvm::BasicBlock *Block)
Add a branch-through to this cleanup scope.
Definition CGCleanup.h:500
llvm::BasicBlock * getBranchAfterBlock(unsigned I) const
Definition CGCleanup.h:475
void AddAuxAllocas(llvm::SmallVector< llvm::AllocaInst * > Allocas)
Definition CGCleanup.h:381
unsigned getNumBranchAfters() const
Return the number of unique branch-afters on this scope.
Definition CGCleanup.h:471
static size_t getSizeForCleanupSize(size_t Size)
Gets the size required for a lazy cleanup scope with the given cleanup-data requirements.
Definition CGCleanup.h:346
bool hasBranches() const
True if this cleanup scope has any branch-afters or branch-throughs.
Definition CGCleanup.h:450
void addBranchAfter(llvm::ConstantInt *Index, llvm::BasicBlock *Block)
Add a branch-after to this cleanup scope.
Definition CGCleanup.h:463
void setActiveFlag(RawAddress Var)
Definition CGCleanup.h:418
EHCleanupScope(bool isNormal, bool isEH, unsigned cleanupSize, unsigned fixupDepth, EHScopeStack::stable_iterator enclosingNormal, EHScopeStack::stable_iterator enclosingEH)
Definition CGCleanup.h:354
EHScopeStack::Cleanup * getCleanup()
Definition CGCleanup.h:445
unsigned getFixupDepth() const
Definition CGCleanup.h:437
static bool classof(const EHScope *Scope)
Definition CGCleanup.h:510
llvm::BasicBlock * getNormalBlock() const
Definition CGCleanup.h:390
bool hasBranchThroughs() const
Determines if this cleanup scope has any branch throughs.
Definition CGCleanup.h:505
An exceptions scope which filters exceptions thrown through it.
Definition CGCleanup.h:528
void setFilter(unsigned i, llvm::Value *filterValue)
Definition CGCleanup.h:553
static size_t getSizeForNumFilters(unsigned numFilters)
Definition CGCleanup.h:547
EHFilterScope(unsigned numFilters)
Definition CGCleanup.h:541
llvm::Value * getFilter(unsigned i) const
Definition CGCleanup.h:558
unsigned getNumFilters() const
Definition CGCleanup.h:551
static bool classof(const EHScope *scope)
Definition CGCleanup.h:563
A non-stable pointer into the scope stack.
Definition CGCleanup.h:582
bool operator!=(iterator other) const
Definition CGCleanup.h:639
bool encloses(iterator other) const
Definition CGCleanup.h:635
bool strictlyEncloses(iterator other) const
Definition CGCleanup.h:636
bool operator==(iterator other) const
Definition CGCleanup.h:638
A saved depth on the scope stack.
A stack of scopes which respond to exceptions, including cleanups and catch blocks.
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
bool empty() const
Determines whether the exception-scopes stack is empty.
iterator end() const
Returns an iterator pointing to the outermost EH scope.
Definition CGCleanup.h:646
iterator begin() const
Returns an iterator pointing to the innermost EH scope.
Definition CGCleanup.h:642
void popCatch()
Pops a catch scope off the stack. This is private to CGException.cpp.
Definition CGCleanup.h:650
iterator find(stable_iterator save) const
Turn a stable reference to a scope depth into a unstable pointer to the EH stack.
Definition CGCleanup.h:666
stable_iterator stabilize(iterator it) const
Translates an iterator into a stable_iterator.
Definition CGCleanup.h:673
void popTerminate()
Pops a terminate handler off the stack.
Definition CGCleanup.h:658
A protected scope for zero-cost EH handling.
Definition CGCleanup.h:46
llvm::BasicBlock * getCachedLandingPad() const
Definition CGCleanup.h:137
EHScope(Kind kind, EHScopeStack::stable_iterator enclosingEHScope)
Definition CGCleanup.h:129
void setCachedLandingPad(llvm::BasicBlock *block)
Definition CGCleanup.h:141
CleanupBitFields CleanupBits
Definition CGCleanup.h:124
FilterBitFields FilterBits
Definition CGCleanup.h:125
EHScopeStack::stable_iterator getEnclosingEHScope() const
Definition CGCleanup.h:159
CatchBitFields CatchBits
Definition CGCleanup.h:123
llvm::BasicBlock * getCachedEHDispatchBlock() const
Definition CGCleanup.h:145
void setCachedEHDispatchBlock(llvm::BasicBlock *block)
Definition CGCleanup.h:149
bool hasEHBranches() const
Definition CGCleanup.h:153
CommonBitFields CommonBits
Definition CGCleanup.h:122
An exceptions scope which calls std::terminate if any exception reaches it.
Definition CGCleanup.h:570
EHTerminateScope(EHScopeStack::stable_iterator enclosingEHScope)
Definition CGCleanup.h:572
static bool classof(const EHScope *scope)
Definition CGCleanup.h:576
An abstract representation of an aligned address.
Definition Address.h:42
CharUnits getAlignment() const
Return the alignment of this pointer.
Definition Address.h:93
Represents a function declaration or definition.
Definition Decl.h:2059
Scope - A scope is a transient data structure that is used while parsing the program.
Definition Scope.h:41
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
Definition CGValue.h:155
const EHPersonality & getEHPersonality(CodeGenModule &CGM, const FunctionDecl *FD)
Selects the personality function to use for FD, or for the translation unit as a whole when FD is nul...
Top level wrappers for InstallAPI frontend operations.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
U cast(CodeGen::Address addr)
Definition Address.h:327
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
The exceptions personality for a function.
The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the type of a catch handler,...
Definition CGCleanup.h:40
CatchTypeInfo Type
A type info value, or null (C++ null, not an LLVM null pointer) for a catch-all.
Definition CGCleanup.h:179
llvm::BasicBlock * Block
The catch handler for this type.
Definition CGCleanup.h:182