Coverage Report

Created: 2018-11-16 02:38

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h
Line
Count
Source (jump to first uncovered line)
1
//===--- llvm/CodeGen/WasmEHFuncInfo.h --------------------------*- C++ -*-===//
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
// Data structures for Wasm exception handling schemes.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CODEGEN_WASMEHFUNCINFO_H
15
#define LLVM_CODEGEN_WASMEHFUNCINFO_H
16
17
#include "llvm/ADT/DenseMap.h"
18
#include "llvm/ADT/PointerUnion.h"
19
#include "llvm/CodeGen/MachineBasicBlock.h"
20
#include "llvm/IR/BasicBlock.h"
21
22
namespace llvm {
23
24
enum EventTag { CPP_EXCEPTION = 0, C_LONGJMP = 1 };
25
26
using BBOrMBB = PointerUnion<const BasicBlock *, MachineBasicBlock *>;
27
28
struct WasmEHFuncInfo {
29
  // When there is an entry <A, B>, if an exception is not caught by A, it
30
  // should next unwind to the EH pad B.
31
  DenseMap<BBOrMBB, BBOrMBB> EHPadUnwindMap;
32
  // For entry <A, B>, A is a BB with an instruction that may throw
33
  // (invoke/cleanupret in LLVM IR, call/rethrow in the backend) and B is an EH
34
  // pad that A unwinds to.
35
  DenseMap<BBOrMBB, BBOrMBB> ThrowUnwindMap;
36
37
  // Helper functions
38
0
  const BasicBlock *getEHPadUnwindDest(const BasicBlock *BB) const {
39
0
    return EHPadUnwindMap.lookup(BB).get<const BasicBlock *>();
40
0
  }
41
3
  void setEHPadUnwindDest(const BasicBlock *BB, const BasicBlock *Dest) {
42
3
    EHPadUnwindMap[BB] = Dest;
43
3
  }
44
0
  const BasicBlock *getThrowUnwindDest(BasicBlock *BB) const {
45
0
    return ThrowUnwindMap.lookup(BB).get<const BasicBlock *>();
46
0
  }
47
35
  void setThrowUnwindDest(const BasicBlock *BB, const BasicBlock *Dest) {
48
35
    ThrowUnwindMap[BB] = Dest;
49
35
  }
50
0
  bool hasEHPadUnwindDest(const BasicBlock *BB) const {
51
0
    return EHPadUnwindMap.count(BB);
52
0
  }
53
0
  bool hasThrowUnwindDest(const BasicBlock *BB) const {
54
0
    return ThrowUnwindMap.count(BB);
55
0
  }
56
57
0
  MachineBasicBlock *getEHPadUnwindDest(MachineBasicBlock *MBB) const {
58
0
    return EHPadUnwindMap.lookup(MBB).get<MachineBasicBlock *>();
59
0
  }
60
0
  void setEHPadUnwindDest(MachineBasicBlock *MBB, MachineBasicBlock *Dest) {
61
0
    EHPadUnwindMap[MBB] = Dest;
62
0
  }
63
4
  MachineBasicBlock *getThrowUnwindDest(MachineBasicBlock *MBB) const {
64
4
    return ThrowUnwindMap.lookup(MBB).get<MachineBasicBlock *>();
65
4
  }
66
0
  void setThrowUnwindDest(MachineBasicBlock *MBB, MachineBasicBlock *Dest) {
67
0
    ThrowUnwindMap[MBB] = Dest;
68
0
  }
69
0
  bool hasEHPadUnwindDest(MachineBasicBlock *MBB) const {
70
0
    return EHPadUnwindMap.count(MBB);
71
0
  }
72
19
  bool hasThrowUnwindDest(MachineBasicBlock *MBB) const {
73
19
    return ThrowUnwindMap.count(MBB);
74
19
  }
75
};
76
77
// Analyze the IR in the given function to build WasmEHFuncInfo.
78
void calculateWasmEHInfo(const Function *F, WasmEHFuncInfo &EHInfo);
79
80
} // namespace llvm
81
82
#endif // LLVM_CODEGEN_WASMEHFUNCINFO_H