Coverage Report

Created: 2019-02-15 18:59

/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
// 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"
14
#include "llvm/ADT/Triple.h"
15
#include "llvm/Support/ErrorHandling.h"
16
17
namespace llvm {
18
class BasicBlock;
19
class Function;
20
class Value;
21
22
enum class EHPersonality {
23
  Unknown,
24
  GNU_Ada,
25
  GNU_C,
26
  GNU_C_SjLj,
27
  GNU_CXX,
28
  GNU_CXX_SjLj,
29
  GNU_ObjC,
30
  MSVC_X86SEH,
31
  MSVC_Win64SEH,
32
  MSVC_CXX,
33
  CoreCLR,
34
  Rust,
35
  Wasm_CXX
36
};
37
38
/// See if the given exception handling personality function is one
39
/// that we understand.  If so, return a description of it; otherwise return
40
/// Unknown.
41
EHPersonality classifyEHPersonality(const Value *Pers);
42
43
StringRef getEHPersonalityName(EHPersonality Pers);
44
45
EHPersonality getDefaultEHPersonality(const Triple &T);
46
47
/// Returns true if this personality function catches asynchronous
48
/// exceptions.
49
23.0k
inline bool isAsynchronousEHPersonality(EHPersonality Pers) {
50
23.0k
  // The two SEH personality functions can catch asynch exceptions. We assume
51
23.0k
  // unknown personalities don't catch asynch exceptions.
52
23.0k
  switch (Pers) {
53
23.0k
  case EHPersonality::MSVC_X86SEH:
54
575
  case EHPersonality::MSVC_Win64SEH:
55
575
    return true;
56
22.5k
  default:
57
22.5k
    return false;
58
0
  }
59
0
  llvm_unreachable("invalid enum");
60
0
}
61
62
/// Returns true if this is a personality function that invokes
63
/// handler funclets (which must return to it).
64
1.02M
inline bool isFuncletEHPersonality(EHPersonality Pers) {
65
1.02M
  switch (Pers) {
66
1.02M
  case EHPersonality::MSVC_CXX:
67
849
  case EHPersonality::MSVC_X86SEH:
68
849
  case EHPersonality::MSVC_Win64SEH:
69
849
  case EHPersonality::CoreCLR:
70
849
    return true;
71
1.02M
  default:
72
1.02M
    return false;
73
0
  }
74
0
  llvm_unreachable("invalid enum");
75
0
}
76
77
/// Returns true if this personality uses scope-style EH IR instructions:
78
/// catchswitch, catchpad/ret, and cleanuppad/ret.
79
644k
inline bool isScopedEHPersonality(EHPersonality Pers) {
80
644k
  switch (Pers) {
81
644k
  case EHPersonality::MSVC_CXX:
82
582
  case EHPersonality::MSVC_X86SEH:
83
582
  case EHPersonality::MSVC_Win64SEH:
84
582
  case EHPersonality::CoreCLR:
85
582
  case EHPersonality::Wasm_CXX:
86
582
    return true;
87
643k
  default:
88
643k
    return false;
89
0
  }
90
0
  llvm_unreachable("invalid enum");
91
0
}
92
93
/// Return true if this personality may be safely removed if there
94
/// are no invoke instructions remaining in the current function.
95
9.71k
inline bool isNoOpWithoutInvoke(EHPersonality Pers) {
96
9.71k
  switch (Pers) {
97
9.71k
  case EHPersonality::Unknown:
98
70
    return false;
99
9.71k
  // All known personalities currently have this behavior
100
9.71k
  default:
101
9.64k
    return true;
102
0
  }
103
0
  llvm_unreachable("invalid enum");
104
0
}
105
106
bool canSimplifyInvokeNoUnwind(const Function *F);
107
108
typedef TinyPtrVector<BasicBlock *> ColorVector;
109
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
113
/// expensive.
114
DenseMap<BasicBlock *, ColorVector> colorEHFunclets(Function &F);
115
116
} // end namespace llvm
117
118
#endif