1 //===- EHPersonalities.h - Compute EH-related information -----------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_ANALYSIS_EHPERSONALITIES_H
10 #define LLVM_ANALYSIS_EHPERSONALITIES_H
12 #include "llvm/ADT/DenseMap.h"
13 #include "llvm/ADT/TinyPtrVector.h"
14 #include "llvm/ADT/Triple.h"
15 #include "llvm/Support/ErrorHandling.h"
22 enum class EHPersonality
{
38 /// See if the given exception handling personality function is one
39 /// that we understand. If so, return a description of it; otherwise return
41 EHPersonality
classifyEHPersonality(const Value
*Pers
);
43 StringRef
getEHPersonalityName(EHPersonality Pers
);
45 EHPersonality
getDefaultEHPersonality(const Triple
&T
);
47 /// Returns true if this personality function catches asynchronous
49 inline bool isAsynchronousEHPersonality(EHPersonality Pers
) {
50 // The two SEH personality functions can catch asynch exceptions. We assume
51 // unknown personalities don't catch asynch exceptions.
53 case EHPersonality::MSVC_X86SEH
:
54 case EHPersonality::MSVC_Win64SEH
:
59 llvm_unreachable("invalid enum");
62 /// Returns true if this is a personality function that invokes
63 /// handler funclets (which must return to it).
64 inline bool isFuncletEHPersonality(EHPersonality Pers
) {
66 case EHPersonality::MSVC_CXX
:
67 case EHPersonality::MSVC_X86SEH
:
68 case EHPersonality::MSVC_Win64SEH
:
69 case EHPersonality::CoreCLR
:
74 llvm_unreachable("invalid enum");
77 /// Returns true if this personality uses scope-style EH IR instructions:
78 /// catchswitch, catchpad/ret, and cleanuppad/ret.
79 inline bool isScopedEHPersonality(EHPersonality Pers
) {
81 case EHPersonality::MSVC_CXX
:
82 case EHPersonality::MSVC_X86SEH
:
83 case EHPersonality::MSVC_Win64SEH
:
84 case EHPersonality::CoreCLR
:
85 case EHPersonality::Wasm_CXX
:
90 llvm_unreachable("invalid enum");
93 /// Return true if this personality may be safely removed if there
94 /// are no invoke instructions remaining in the current function.
95 inline bool isNoOpWithoutInvoke(EHPersonality Pers
) {
97 case EHPersonality::Unknown
:
99 // All known personalities currently have this behavior
103 llvm_unreachable("invalid enum");
106 bool canSimplifyInvokeNoUnwind(const Function
*F
);
108 typedef TinyPtrVector
<BasicBlock
*> ColorVector
;
110 /// If an EH funclet personality is in use (see isFuncletEHPersonality),
111 /// this will recompute which blocks are in which funclet. It is possible that
112 /// some blocks are in multiple funclets. Consider this analysis to be
114 DenseMap
<BasicBlock
*, ColorVector
> colorEHFunclets(Function
&F
);
116 } // end namespace llvm