LCOV - code coverage report
Current view: top level - include/llvm/CodeGen - WasmEHFuncInfo.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 5 6 83.3 %
Date: 2018-10-20 13:21:21 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : using BBOrMBB = PointerUnion<const BasicBlock *, MachineBasicBlock *>;
      25             : 
      26         212 : 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             :   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           2 :     EHPadUnwindMap[BB] = Dest;
      41             :   }
      42             :   const BasicBlock *getThrowUnwindDest(BasicBlock *BB) const {
      43             :     return ThrowUnwindMap.lookup(BB).get<const BasicBlock *>();
      44             :   }
      45             :   void setThrowUnwindDest(const BasicBlock *BB, const BasicBlock *Dest) {
      46          20 :     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             : 
      55             :   MachineBasicBlock *getEHPadUnwindDest(MachineBasicBlock *MBB) const {
      56             :     return EHPadUnwindMap.lookup(MBB).get<MachineBasicBlock *>();
      57             :   }
      58             :   void setEHPadUnwindDest(MachineBasicBlock *MBB, MachineBasicBlock *Dest) {
      59             :     EHPadUnwindMap[MBB] = Dest;
      60             :   }
      61           3 :   MachineBasicBlock *getThrowUnwindDest(MachineBasicBlock *MBB) const {
      62           3 :     return ThrowUnwindMap.lookup(MBB).get<MachineBasicBlock *>();
      63             :   }
      64             :   void setThrowUnwindDest(MachineBasicBlock *MBB, MachineBasicBlock *Dest) {
      65             :     ThrowUnwindMap[MBB] = Dest;
      66             :   }
      67             :   bool hasEHPadUnwindDest(MachineBasicBlock *MBB) const {
      68             :     return EHPadUnwindMap.count(MBB);
      69             :   }
      70             :   bool hasThrowUnwindDest(MachineBasicBlock *MBB) const {
      71           0 :     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

Generated by: LCOV version 1.13