summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2018-10-16 00:09:12 +0000
committerHeejin Ahn <aheejin@gmail.com>2018-10-16 00:09:12 +0000
commit0981eaab4766ebfdc355c8de8d4dad67f879efb6 (patch)
tree463f65162769d167600a240ffdaed9fe4f324c5e /llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
parent93a38d60be274159aafe32440d768dcd0e9cd2df (diff)
downloadbcm5719-llvm-0981eaab4766ebfdc355c8de8d4dad67f879efb6.tar.gz
bcm5719-llvm-0981eaab4766ebfdc355c8de8d4dad67f879efb6.zip
[WebAssembly] LSDA info generation
Summary: This adds support for LSDA (exception table) generation for wasm EH. Wasm EH mostly follows the structure of Itanium-style exception tables, with one exception: a call site table entry in wasm EH corresponds to not a call site but a landing pad. In wasm EH, the VM is responsible for stack unwinding. After an exception occurs and the stack is unwound, the control flow is transferred to wasm 'catch' instruction by the VM, after which the personality function is called from the compiler-generated code. (Refer to WasmEHPrepare pass for more information on this part.) This patch: - Changes wasm.landingpad.index intrinsic to take a token argument, to make this 1:1 match with a catchpad instruction - Stores landingpad index info and catch type info MachineFunction in before instruction selection - Lowers wasm.lsda intrinsic to an MCSymbol pointing to the start of an exception table - Adds WasmException class with overridden methods for table generation - Adds support for LSDA section in Wasm object writer Reviewers: dschuff, sbc100, rnk Subscribers: mgorny, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D52748 llvm-svn: 344575
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp b/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
index be04b9a6e8c..7599121de2b 100644
--- a/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
@@ -345,7 +345,9 @@ computeCallSiteTable(SmallVectorImpl<CallSiteEntry> &CallSites,
/// unwound and handling continues.
/// 3. Type ID table contains references to all the C++ typeinfo for all
/// catches in the function. This tables is reverse indexed base 1.
-void EHStreamer::emitExceptionTable() {
+///
+/// Returns the starting symbol of an exception table.
+MCSymbol *EHStreamer::emitExceptionTable() {
const MachineFunction *MF = Asm->MF;
const std::vector<const GlobalValue *> &TypeInfos = MF->getTypeInfos();
const std::vector<unsigned> &FilterIds = MF->getFilterIds();
@@ -375,6 +377,7 @@ void EHStreamer::emitExceptionTable() {
computeCallSiteTable(CallSites, LandingPads, FirstActions);
bool IsSJLJ = Asm->MAI->getExceptionHandlingType() == ExceptionHandling::SjLj;
+ bool IsWasm = Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Wasm;
unsigned CallSiteEncoding =
IsSJLJ ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_uleb128;
bool HaveTTData = !TypeInfos.empty() || !FilterIds.empty();
@@ -457,8 +460,8 @@ void EHStreamer::emitExceptionTable() {
Asm->EmitLabelDifferenceAsULEB128(CstEndLabel, CstBeginLabel);
Asm->OutStreamer->EmitLabel(CstBeginLabel);
- // SjLj Exception handling
- if (IsSJLJ) {
+ // SjLj / Wasm Exception handling
+ if (IsSJLJ || IsWasm) {
unsigned idx = 0;
for (SmallVectorImpl<CallSiteEntry>::const_iterator
I = CallSites.begin(), E = CallSites.end(); I != E; ++I, ++idx) {
@@ -604,6 +607,7 @@ void EHStreamer::emitExceptionTable() {
}
Asm->EmitAlignment(2);
+ return GCCETSym;
}
void EHStreamer::emitTypeInfos(unsigned TTypeEncoding, MCSymbol *TTBaseLabel) {
OpenPOWER on IntegriCloud