Coverage Report

Created: 2018-09-23 22:08

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Analysis/EHPersonalities.h
Line
Count
Source (jump to first uncovered line)
1
//===- EHPersonalities.h - Compute EH-related information -----------------===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLVM_ANALYSIS_EHPERSONALITIES_H
11
#define LLVM_ANALYSIS_EHPERSONALITIES_H
12
13
#include "llvm/ADT/DenseMap.h"
14
#include "llvm/ADT/TinyPtrVector.h"
15
#include "llvm/ADT/Triple.h"
16
#include "llvm/Support/ErrorHandling.h"
17
18
namespace llvm {
19
class BasicBlock;
20
class Function;
21
class Value;
22
23
enum class EHPersonality {
24
  Unknown,
25
  GNU_Ada,
26
  GNU_C,
27
  GNU_C_SjLj,
28
  GNU_CXX,
29
  GNU_CXX_SjLj,
30
  GNU_ObjC,
31
  MSVC_X86SEH,
32
  MSVC_Win64SEH,
33
  MSVC_CXX,
34
  CoreCLR,
35
  Rust,
36
  Wasm_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.
42
EHPersonality classifyEHPersonality(const Value *Pers);
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.
50
37.8k
inline bool isAsynchronousEHPersonality(EHPersonality Pers) {
51
37.8k
  // The two SEH personality functions can catch asynch exceptions. We assume
52
37.8k
  // unknown personalities don't catch asynch exceptions.
53
37.8k
  switch (Pers) {
54
37.8k
  case EHPersonality::MSVC_X86SEH:
55
495
  case EHPersonality::MSVC_Win64SEH:
56
495
    return true;
57
37.3k
  default:
58
37.3k
    return false;
59
0
  }
60
0
  llvm_unreachable("invalid enum");
61
0
}
62
63
/// Returns true if this is a personality function that invokes
64
/// handler funclets (which must return to it).
65
1.05M
inline bool isFuncletEHPersonality(EHPersonality Pers) {
66
1.05M
  switch (Pers) {
67
1.05M
  case EHPersonality::MSVC_CXX:
68
591
  case EHPersonality::MSVC_X86SEH:
69
591
  case EHPersonality::MSVC_Win64SEH:
70
591
  case EHPersonality::CoreCLR:
71
591
    return true;
72
1.05M
  default:
73
1.05M
    return false;
74
0
  }
75
0
  llvm_unreachable("invalid enum");
76
0
}
77
78
/// Returns true if this personality uses scope-style EH IR instructions:
79
/// catchswitch, catchpad/ret, and cleanuppad/ret.
80
646k
inline bool isScopedEHPersonality(EHPersonality Pers) {
81
646k
  switch (Pers) {
82
646k
  case EHPersonality::MSVC_CXX:
83
468
  case EHPersonality::MSVC_X86SEH:
84
468
  case EHPersonality::MSVC_Win64SEH:
85
468
  case EHPersonality::CoreCLR:
86
468
  case EHPersonality::Wasm_CXX:
87
468
    return true;
88
645k
  default:
89
645k
    return false;
90
0
  }
91
0
  llvm_unreachable("invalid enum");
92
0
}
93
94
/// Return true if this personality may be safely removed if there
95
/// are no invoke instructions remaining in the current function.
96
9.37k
inline bool isNoOpWithoutInvoke(EHPersonality Pers) {
97
9.37k
  switch (Pers) {
98
9.37k
  case EHPersonality::Unknown:
99
68
    return false;
100
9.37k
  // All known personalities currently have this behavior
101
9.37k
  default:
102
9.30k
    return true;
103
0
  }
104
0
  llvm_unreachable("invalid enum");
105
0
}
106
107
bool canSimplifyInvokeNoUnwind(const Function *F);
108
109
typedef TinyPtrVector<BasicBlock *> ColorVector;
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.
115
DenseMap<BasicBlock *, ColorVector> colorEHFunclets(Function &F);
116
117
} // end namespace llvm
118
119
#endif