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