LLVM  7.0.0
WasmEHFuncInfo.h
Go to the documentation of this file.
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"
20 #include "llvm/IR/BasicBlock.h"
21 
22 namespace llvm {
23 
25 
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.
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.
34 
35  // Helper functions
36  const BasicBlock *getEHPadUnwindDest(const BasicBlock *BB) const {
37  return EHPadUnwindMap.lookup(BB).get<const BasicBlock *>();
38  }
39  void setEHPadUnwindDest(const BasicBlock *BB, const BasicBlock *Dest) {
40  EHPadUnwindMap[BB] = Dest;
41  }
43  return ThrowUnwindMap.lookup(BB).get<const BasicBlock *>();
44  }
45  void setThrowUnwindDest(const BasicBlock *BB, const BasicBlock *Dest) {
46  ThrowUnwindMap[BB] = Dest;
47  }
48  bool hasEHPadUnwindDest(const BasicBlock *BB) const {
49  return EHPadUnwindMap.count(BB);
50  }
51  bool hasThrowUnwindDest(const BasicBlock *BB) const {
52  return ThrowUnwindMap.count(BB);
53  }
54 
56  return EHPadUnwindMap.lookup(MBB).get<MachineBasicBlock *>();
57  }
59  EHPadUnwindMap[MBB] = Dest;
60  }
62  return ThrowUnwindMap.lookup(MBB).get<MachineBasicBlock *>();
63  }
65  ThrowUnwindMap[MBB] = Dest;
66  }
68  return EHPadUnwindMap.count(MBB);
69  }
71  return ThrowUnwindMap.count(MBB);
72  }
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
const BasicBlock * getThrowUnwindDest(BasicBlock *BB) const
bool hasEHPadUnwindDest(const BasicBlock *BB) const
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
F(f)
bool hasThrowUnwindDest(MachineBasicBlock *MBB) const
void setEHPadUnwindDest(MachineBasicBlock *MBB, MachineBasicBlock *Dest)
DenseMap< BBOrMBB, BBOrMBB > EHPadUnwindMap
DenseMap< BBOrMBB, BBOrMBB > ThrowUnwindMap
MachineBasicBlock * getThrowUnwindDest(MachineBasicBlock *MBB) const
LLVM Basic Block Representation.
Definition: BasicBlock.h:59
void setEHPadUnwindDest(const BasicBlock *BB, const BasicBlock *Dest)
const BasicBlock * getEHPadUnwindDest(const BasicBlock *BB) const
bool hasThrowUnwindDest(const BasicBlock *BB) const
bool hasEHPadUnwindDest(MachineBasicBlock *MBB) const
void calculateWasmEHInfo(const Function *F, WasmEHFuncInfo &EHInfo)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition: DenseMap.h:141
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:181
void setThrowUnwindDest(MachineBasicBlock *MBB, MachineBasicBlock *Dest)
void setThrowUnwindDest(const BasicBlock *BB, const BasicBlock *Dest)
MachineBasicBlock * getEHPadUnwindDest(MachineBasicBlock *MBB) const
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...
Definition: PointerUnion.h:87