1 //===- EHPersonalities.h - Compute EH-related information -----------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_ANALYSIS_EHPERSONALITIES_H
11 #define LLVM_ANALYSIS_EHPERSONALITIES_H
13 #include "llvm/ADT/DenseMap.h"
14 #include "llvm/ADT/TinyPtrVector.h"
15 #include "llvm/ADT/Triple.h"
16 #include "llvm/Support/ErrorHandling.h"
23 enum class EHPersonality {
39 /// See if the given exception handling personality function is one
40 /// that we understand. If so, return a description of it; otherwise return
42 EHPersonality classifyEHPersonality(const Value *Pers);
44 StringRef getEHPersonalityName(EHPersonality Pers);
46 EHPersonality getDefaultEHPersonality(const Triple &T);
48 /// Returns true if this personality function catches asynchronous
50 inline bool isAsynchronousEHPersonality(EHPersonality Pers) {
51 // The two SEH personality functions can catch asynch exceptions. We assume
52 // unknown personalities don't catch asynch exceptions.
54 case EHPersonality::MSVC_X86SEH:
55 case EHPersonality::MSVC_Win64SEH:
60 llvm_unreachable("invalid enum");
63 /// Returns true if this is a personality function that invokes
64 /// handler funclets (which must return to it).
65 inline bool isFuncletEHPersonality(EHPersonality Pers) {
67 case EHPersonality::MSVC_CXX:
68 case EHPersonality::MSVC_X86SEH:
69 case EHPersonality::MSVC_Win64SEH:
70 case EHPersonality::CoreCLR:
75 llvm_unreachable("invalid enum");
78 /// Returns true if this personality uses scope-style EH IR instructions:
79 /// catchswitch, catchpad/ret, and cleanuppad/ret.
80 inline bool isScopedEHPersonality(EHPersonality Pers) {
82 case EHPersonality::MSVC_CXX:
83 case EHPersonality::MSVC_X86SEH:
84 case EHPersonality::MSVC_Win64SEH:
85 case EHPersonality::CoreCLR:
86 case EHPersonality::Wasm_CXX:
91 llvm_unreachable("invalid enum");
94 /// Return true if this personality may be safely removed if there
95 /// are no invoke instructions remaining in the current function.
96 inline bool isNoOpWithoutInvoke(EHPersonality Pers) {
98 case EHPersonality::Unknown:
100 // All known personalities currently have this behavior
104 llvm_unreachable("invalid enum");
107 bool canSimplifyInvokeNoUnwind(const Function *F);
109 typedef TinyPtrVector<BasicBlock *> ColorVector;
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
115 DenseMap<BasicBlock *, ColorVector> colorEHFunclets(Function &F);
117 } // end namespace llvm