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