Coverage Report

Created: 2019-07-24 05:18

/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
// 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
// Data structures for Wasm exception handling schemes.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CODEGEN_WASMEHFUNCINFO_H
14
#define LLVM_CODEGEN_WASMEHFUNCINFO_H
15
16
#include "llvm/ADT/DenseMap.h"
17
#include "llvm/ADT/PointerUnion.h"
18
#include "llvm/CodeGen/MachineBasicBlock.h"
19
#include "llvm/IR/BasicBlock.h"
20
21
namespace llvm {
22
23
enum EventTag { CPP_EXCEPTION = 0, C_LONGJMP = 1 };
24
25
using BBOrMBB = PointerUnion<const BasicBlock *, MachineBasicBlock *>;
26
27
struct WasmEHFuncInfo {
28
  // When there is an entry <A, B>, if an exception is not caught by A, it
29
  // should next unwind to the EH pad B.
30
  DenseMap<BBOrMBB, BBOrMBB> EHPadUnwindMap;
31
32
  // Helper functions
33
0
  const BasicBlock *getEHPadUnwindDest(const BasicBlock *BB) const {
34
0
    return EHPadUnwindMap.lookup(BB).get<const BasicBlock *>();
35
0
  }
36
3
  void setEHPadUnwindDest(const BasicBlock *BB, const BasicBlock *Dest) {
37
3
    EHPadUnwindMap[BB] = Dest;
38
3
  }
39
0
  bool hasEHPadUnwindDest(const BasicBlock *BB) const {
40
0
    return EHPadUnwindMap.count(BB);
41
0
  }
42
43
3
  MachineBasicBlock *getEHPadUnwindDest(MachineBasicBlock *MBB) const {
44
3
    return EHPadUnwindMap.lookup(MBB).get<MachineBasicBlock *>();
45
3
  }
46
0
  void setEHPadUnwindDest(MachineBasicBlock *MBB, MachineBasicBlock *Dest) {
47
0
    EHPadUnwindMap[MBB] = Dest;
48
0
  }
49
36
  bool hasEHPadUnwindDest(MachineBasicBlock *MBB) const {
50
36
    return EHPadUnwindMap.count(MBB);
51
36
  }
52
};
53
54
// Analyze the IR in the given function to build WasmEHFuncInfo.
55
void calculateWasmEHInfo(const Function *F, WasmEHFuncInfo &EHInfo);
56
57
} // namespace llvm
58
59
#endif // LLVM_CODEGEN_WASMEHFUNCINFO_H