diff options
author | Heejin Ahn <aheejin@gmail.com> | 2018-10-25 23:55:10 +0000 |
---|---|---|
committer | Heejin Ahn <aheejin@gmail.com> | 2018-10-25 23:55:10 +0000 |
commit | 24faf859e52b5d06068c3696ca1c89c09ffa2698 (patch) | |
tree | 6c73010ae3a2ec0679d681e8b397f7e05463371f /llvm/lib/MC | |
parent | 223307b3dc0c7696c2fbad2104223d7064867adb (diff) | |
download | bcm5719-llvm-24faf859e52b5d06068c3696ca1c89c09ffa2698.tar.gz bcm5719-llvm-24faf859e52b5d06068c3696ca1c89c09ffa2698.zip |
Reland "[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: 345345
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r-- | llvm/lib/MC/MCObjectFileInfo.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/MC/WasmObjectWriter.cpp | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index 465b62ce8c9..54d8d4e5f71 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -746,6 +746,12 @@ void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) { DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", SectionKind::getMetadata()); DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", SectionKind::getMetadata()); + // Wasm use data section for LSDA. + // TODO Consider putting each function's exception table in a separate + // section, as in -function-sections, to facilitate lld's --gc-section. + LSDASection = Ctx->getWasmSection(".rodata.gcc_except_table", + SectionKind::getReadOnlyWithRel()); + // TODO: Define more sections. } diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index cbbe161ae82..f9318ad5801 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -635,10 +635,12 @@ static void addData(SmallVectorImpl<char> &DataBytes, llvm_unreachable("The fill should be an assembler constant"); DataBytes.insert(DataBytes.end(), Fill->getValueSize() * NumValues, Fill->getValue()); + } else if (auto *LEB = dyn_cast<MCLEBFragment>(&Frag)) { + const SmallVectorImpl<char> &Contents = LEB->getContents(); + DataBytes.insert(DataBytes.end(), Contents.begin(), Contents.end()); } else { const auto &DataFrag = cast<MCDataFragment>(Frag); const SmallVectorImpl<char> &Contents = DataFrag.getContents(); - DataBytes.insert(DataBytes.end(), Contents.begin(), Contents.end()); } } |