LLVM  14.0.0git
EHPersonalities.h
Go to the documentation of this file.
1 //===- EHPersonalities.h - Compute EH-related information -----------------===//
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 #ifndef LLVM_ANALYSIS_EHPERSONALITIES_H
10 #define LLVM_ANALYSIS_EHPERSONALITIES_H
11 
12 #include "llvm/ADT/DenseMap.h"
13 #include "llvm/ADT/TinyPtrVector.h"
15 
16 namespace llvm {
17 class BasicBlock;
18 class Function;
19 class Triple;
20 class Value;
21 
22 enum class EHPersonality {
23  Unknown,
24  GNU_Ada,
25  GNU_C,
26  GNU_C_SjLj,
27  GNU_CXX,
29  GNU_ObjC,
32  MSVC_CXX,
33  CoreCLR,
34  Rust,
35  Wasm_CXX,
36  XL_CXX
37 };
38 
39 /// See if the given exception handling personality function is one
40 /// that we understand. If so, return a description of it; otherwise return
41 /// Unknown.
43 
44 StringRef getEHPersonalityName(EHPersonality Pers);
45 
46 EHPersonality getDefaultEHPersonality(const Triple &T);
47 
48 /// Returns true if this personality function catches asynchronous
49 /// exceptions.
51  // The two SEH personality functions can catch asynch exceptions. We assume
52  // unknown personalities don't catch asynch exceptions.
53  switch (Pers) {
56  return true;
57  default:
58  return false;
59  }
60  llvm_unreachable("invalid enum");
61 }
62 
63 /// Returns true if this is a personality function that invokes
64 /// handler funclets (which must return to it).
66  switch (Pers) {
71  return true;
72  default:
73  return false;
74  }
75  llvm_unreachable("invalid enum");
76 }
77 
78 /// Returns true if this personality uses scope-style EH IR instructions:
79 /// catchswitch, catchpad/ret, and cleanuppad/ret.
81  switch (Pers) {
87  return true;
88  default:
89  return false;
90  }
91  llvm_unreachable("invalid enum");
92 }
93 
94 /// Return true if this personality may be safely removed if there
95 /// are no invoke instructions remaining in the current function.
97  switch (Pers) {
99  return false;
100  // All known personalities currently have this behavior
101  default:
102  return true;
103  }
104  llvm_unreachable("invalid enum");
105 }
106 
107 bool canSimplifyInvokeNoUnwind(const Function *F);
108 
110 
111 /// If an EH funclet personality is in use (see isFuncletEHPersonality),
112 /// this will recompute which blocks are in which funclet. It is possible that
113 /// some blocks are in multiple funclets. Consider this analysis to be
114 /// expensive.
116 
117 } // end namespace llvm
118 
119 #endif
llvm::EHPersonality::MSVC_CXX
@ MSVC_CXX
llvm::isAsynchronousEHPersonality
bool isAsynchronousEHPersonality(EHPersonality Pers)
Returns true if this personality function catches asynchronous exceptions.
Definition: EHPersonalities.h:50
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::EHPersonality::GNU_C_SjLj
@ GNU_C_SjLj
llvm::EHPersonality::GNU_Ada
@ GNU_Ada
llvm::ColorVector
TinyPtrVector< BasicBlock * > ColorVector
Definition: EHPersonalities.h:109
llvm::Function
Definition: Function.h:61
ErrorHandling.h
DenseMap.h
llvm::EHPersonality::GNU_ObjC
@ GNU_ObjC
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::classifyEHPersonality
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
Definition: EHPersonalities.cpp:21
llvm::EHPersonality::GNU_C
@ GNU_C
llvm::isNoOpWithoutInvoke
bool isNoOpWithoutInvoke(EHPersonality Pers)
Return true if this personality may be safely removed if there are no invoke instructions remaining i...
Definition: EHPersonalities.h:96
llvm::EHPersonality::Wasm_CXX
@ Wasm_CXX
llvm::EHPersonality::GNU_CXX_SjLj
@ GNU_CXX_SjLj
llvm::colorEHFunclets
DenseMap< BasicBlock *, ColorVector > colorEHFunclets(Function &F)
If an EH funclet personality is in use (see isFuncletEHPersonality), this will recompute which blocks...
Definition: EHPersonalities.cpp:81
llvm::canSimplifyInvokeNoUnwind
bool canSimplifyInvokeNoUnwind(const Function *F)
Definition: EHPersonalities.cpp:73
llvm::DenseMap
Definition: DenseMap.h:714
llvm::isScopedEHPersonality
bool isScopedEHPersonality(EHPersonality Pers)
Returns true if this personality uses scope-style EH IR instructions: catchswitch,...
Definition: EHPersonalities.h:80
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
llvm::getEHPersonalityName
StringRef getEHPersonalityName(EHPersonality Pers)
Definition: EHPersonalities.cpp:46
TinyPtrVector.h
llvm::EHPersonality::CoreCLR
@ CoreCLR
llvm::EHPersonality::MSVC_TableSEH
@ MSVC_TableSEH
llvm::EHPersonality::GNU_CXX
@ GNU_CXX
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::EHPersonality::XL_CXX
@ XL_CXX
llvm::getDefaultEHPersonality
EHPersonality getDefaultEHPersonality(const Triple &T)
Definition: EHPersonalities.cpp:69
llvm::EHPersonality
EHPersonality
Definition: EHPersonalities.h:22
llvm::EHPersonality::MSVC_X86SEH
@ MSVC_X86SEH
llvm::EHPersonality::Unknown
@ Unknown
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::EHPersonality::Rust
@ Rust
llvm::TinyPtrVector
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
Definition: TinyPtrVector.h:30
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::isFuncletEHPersonality
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
Definition: EHPersonalities.h:65