Coverage Report

Created: 2018-07-18 22:01

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