Skip to content

Commit c09acd5

Browse files
committed
[WebAssembly] Handle event exports
Summary: This handles exports of events, which was missing. Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77566
1 parent 3a29393 commit c09acd5

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lld/test/wasm/event-section.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %p/Inputs/event-section2.ll -o %t2.o
33
; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %s -o %t.o
44
; RUN: wasm-ld -o %t.wasm %t.o %t1.o %t2.o
5+
; RUN: wasm-ld --export-all -o %t-export-all.wasm %t.o %t1.o %t2.o
56
; RUN: obj2yaml %t.wasm | FileCheck %s
7+
; RUN: obj2yaml %t-export-all.wasm | FileCheck %s --check-prefix=EXPORT-ALL
68

79
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
810
target triple = "wasm32-unknown-unknown"
@@ -35,3 +37,9 @@ define void @_start() {
3537

3638
; Global section has to come after event section
3739
; CHECK: - Type: GLOBAL
40+
41+
; EXPORT-ALL: - Type: EXPORT
42+
; EXPORT-ALL-NEXT Exports:
43+
; EXPORT-ALL: - Name: __cpp_exception
44+
; EXPORT-ALL: Kind: EVENT
45+
; EXPORT-ALL: Index: 0

lld/wasm/WriterUtils.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ void writeExport(raw_ostream &os, const WasmExport &export_) {
217217
case WASM_EXTERNAL_GLOBAL:
218218
writeUleb128(os, export_.Index, "global index");
219219
break;
220+
case WASM_EXTERNAL_EVENT:
221+
writeUleb128(os, export_.Index, "event index");
222+
break;
220223
case WASM_EXTERNAL_MEMORY:
221224
writeUleb128(os, export_.Index, "memory index");
222225
break;

0 commit comments

Comments
 (0)