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 {
38 /// \brief 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 /// \brief 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 /// \brief 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 /// \brief Return true if this personality may be safely removed if there
78 /// are no invoke instructions remaining in the current function.
79 inline bool isNoOpWithoutInvoke(EHPersonality Pers) {
81 case EHPersonality::Unknown:
83 // All known personalities currently have this behavior
87 llvm_unreachable("invalid enum");
90 bool canSimplifyInvokeNoUnwind(const Function *F);
92 typedef TinyPtrVector<BasicBlock *> ColorVector;
94 /// \brief If an EH funclet personality is in use (see isFuncletEHPersonality),
95 /// this will recompute which blocks are in which funclet. It is possible that
96 /// some blocks are in multiple funclets. Consider this analysis to be
98 DenseMap<BasicBlock *, ColorVector> colorEHFunclets(Function &F);
100 } // end namespace llvm