File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -414,7 +414,19 @@ struct LegalizeAndPruneJSInterface : public LegalizeJSInterface {
414414 ReFinalize ().run (getPassRunner (), module );
415415 ReFinalize ().runOnModuleCode (getPassRunner (), module );
416416
417- // TODO: globals etc.
417+ // Globals.
418+ std::vector<Name> illegalExports;
419+ for (auto & exp : module ->exports ) {
420+ if (exp->kind == ExternalKind::Global) {
421+ auto name = *exp->getInternalName ();
422+ if (isIllegal (module ->getGlobal (name)->type )) {
423+ illegalExports.push_back (exp->name );
424+ }
425+ }
426+ }
427+ for (auto name : illegalExports) {
428+ module ->removeExport (name);
429+ }
418430 }
419431
420432 bool isIllegal (Type type) {
Original file line number Diff line number Diff line change 245245 ;; and also prune the export, so it remains neither an import nor an export.
246246 (export " imported-v128" (func $imported-v128 ))
247247)
248+
248249;; CHECK: (type $0 (func (result v128)))
249250
250251;; CHECK: (func $imported-v128 (type $0) (result v128)
251252;; CHECK-NEXT: (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000)
252253;; CHECK-NEXT: )
254+ (module
255+ ;; CHECK: (global $i32 i32 (i32.const 42))
256+ (global $i32 i32 (i32.const 42 ))
257+
258+ ;; CHECK: (global $v128 v128 (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000))
259+ (global $v128 v128 (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000 ))
260+
261+ ;; The illegal export will vanish, but not the legal one.
262+
263+ (export " illegal" (global $v128 ))
264+ ;; CHECK: (export "legal" (global $i32))
265+ (export " legal" (global $i32 ))
266+ )
267+
You can’t perform that action at this time.
0 commit comments