LLVM  14.0.0git
WasmEHFuncInfo.h
Go to the documentation of this file.
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/ADT/SmallPtrSet.h"
19 
20 namespace llvm {
21 
22 class BasicBlock;
23 class Function;
24 class MachineBasicBlock;
25 
26 namespace WebAssembly {
27 enum Tag { CPP_EXCEPTION = 0, C_LONGJMP = 1 };
28 }
29 
31 
33  // When there is an entry <A, B>, if an exception is not caught by A, it
34  // should next unwind to the EH pad B.
37 
38  // Helper functions
39  const BasicBlock *getUnwindDest(const BasicBlock *BB) const {
41  return SrcToUnwindDest.lookup(BB).get<const BasicBlock *>();
42  }
45  const auto &Set = UnwindDestToSrcs.lookup(BB);
47  for (const auto P : Set)
48  Ret.insert(P.get<const BasicBlock *>());
49  return Ret;
50  }
51  void setUnwindDest(const BasicBlock *BB, const BasicBlock *Dest) {
52  SrcToUnwindDest[BB] = Dest;
53  if (!UnwindDestToSrcs.count(Dest))
55  UnwindDestToSrcs[Dest].insert(BB);
56  }
57  bool hasUnwindDest(const BasicBlock *BB) const {
58  return SrcToUnwindDest.count(BB);
59  }
60  bool hasUnwindSrcs(const BasicBlock *BB) const {
61  return UnwindDestToSrcs.count(BB);
62  }
63 
66  return SrcToUnwindDest.lookup(MBB).get<MachineBasicBlock *>();
67  }
71  const auto &Set = UnwindDestToSrcs.lookup(MBB);
73  for (const auto P : Set)
74  Ret.insert(P.get<MachineBasicBlock *>());
75  return Ret;
76  }
78  SrcToUnwindDest[MBB] = Dest;
79  if (!UnwindDestToSrcs.count(Dest))
81  UnwindDestToSrcs[Dest].insert(MBB);
82  }
84  return SrcToUnwindDest.count(MBB);
85  }
87  return UnwindDestToSrcs.count(MBB);
88  }
89 };
90 
91 // Analyze the IR in the given function to build WasmEHFuncInfo.
92 void calculateWasmEHInfo(const Function *F, WasmEHFuncInfo &EHInfo);
93 
94 } // namespace llvm
95 
96 #endif // LLVM_CODEGEN_WASMEHFUNCINFO_H
llvm::WasmEHFuncInfo
Definition: WasmEHFuncInfo.h:32
llvm::WasmEHFuncInfo::setUnwindDest
void setUnwindDest(const BasicBlock *BB, const BasicBlock *Dest)
Definition: WasmEHFuncInfo.h:51
llvm::WasmEHFuncInfo::getUnwindSrcs
SmallPtrSet< MachineBasicBlock *, 4 > getUnwindSrcs(MachineBasicBlock *MBB) const
Definition: WasmEHFuncInfo.h:69
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::WasmEHFuncInfo::hasUnwindSrcs
bool hasUnwindSrcs(MachineBasicBlock *MBB) const
Definition: WasmEHFuncInfo.h:86
llvm::WebAssembly::C_LONGJMP
@ C_LONGJMP
Definition: WasmEHFuncInfo.h:27
llvm::WasmEHFuncInfo::getUnwindDest
MachineBasicBlock * getUnwindDest(MachineBasicBlock *MBB) const
Definition: WasmEHFuncInfo.h:64
DenseMap.h
llvm::SmallPtrSet< const BasicBlock *, 4 >
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:116
llvm::WebAssembly::Tag
Tag
Definition: WasmEHFuncInfo.h:27
llvm::WasmEHFuncInfo::hasUnwindDest
bool hasUnwindDest(const BasicBlock *BB) const
Definition: WasmEHFuncInfo.h:57
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
SmallPtrSet.h
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::WasmEHFuncInfo::hasUnwindSrcs
bool hasUnwindSrcs(const BasicBlock *BB) const
Definition: WasmEHFuncInfo.h:60
llvm::DenseMap
Definition: DenseMap.h:714
llvm::WasmEHFuncInfo::getUnwindDest
const BasicBlock * getUnwindDest(const BasicBlock *BB) const
Definition: WasmEHFuncInfo.h:39
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
PointerUnion.h
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
llvm::WasmEHFuncInfo::SrcToUnwindDest
DenseMap< BBOrMBB, BBOrMBB > SrcToUnwindDest
Definition: WasmEHFuncInfo.h:35
llvm::WasmEHFuncInfo::getUnwindSrcs
SmallPtrSet< const BasicBlock *, 4 > getUnwindSrcs(const BasicBlock *BB) const
Definition: WasmEHFuncInfo.h:43
llvm::ReplayInlineScope::Function
@ Function
llvm::WasmEHFuncInfo::hasUnwindDest
bool hasUnwindDest(MachineBasicBlock *MBB) const
Definition: WasmEHFuncInfo.h:83
llvm::PointerUnion< const BasicBlock *, MachineBasicBlock * >
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::WebAssembly::CPP_EXCEPTION
@ CPP_EXCEPTION
Definition: WasmEHFuncInfo.h:27
llvm::WasmEHFuncInfo::UnwindDestToSrcs
DenseMap< BBOrMBB, SmallPtrSet< BBOrMBB, 4 > > UnwindDestToSrcs
Definition: WasmEHFuncInfo.h:36
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::WasmEHFuncInfo::setUnwindDest
void setUnwindDest(MachineBasicBlock *MBB, MachineBasicBlock *Dest)
Definition: WasmEHFuncInfo.h:77
llvm::calculateWasmEHInfo
void calculateWasmEHInfo(const Function *F, WasmEHFuncInfo &EHInfo)
Definition: WasmEHPrepare.cpp:343