[lld][WebAssemby] Allow import module names to be empty strings.
The component-model [canonical ABI] is currently using import names with empty strings. Remove the special cases for empty strings from WasmObjectFile.cpp so that they can pass through as-is. [canonical ABI]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md Differential Revision: https://reviews.llvm.org/D133037
This commit is contained in:
parent
7e52e0fc72
commit
9f049e9993
|
@ -6,12 +6,15 @@ target triple = "wasm32-unknown-unknown-wasm"
|
||||||
|
|
||||||
define void @_start() {
|
define void @_start() {
|
||||||
call void @foo();
|
call void @foo();
|
||||||
|
call void @qux();
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
declare void @foo() #0
|
declare void @foo() #0
|
||||||
|
declare void @qux() #1
|
||||||
|
|
||||||
attributes #0 = { "wasm-import-module"="bar" }
|
attributes #0 = { "wasm-import-module"="bar" }
|
||||||
|
attributes #1 = { "wasm-import-module"="" }
|
||||||
|
|
||||||
; CHECK: - Type: IMPORT
|
; CHECK: - Type: IMPORT
|
||||||
; CHECK-NEXT: Imports:
|
; CHECK-NEXT: Imports:
|
||||||
|
@ -19,3 +22,7 @@ attributes #0 = { "wasm-import-module"="bar" }
|
||||||
; CHECK-NEXT: Field: foo
|
; CHECK-NEXT: Field: foo
|
||||||
; CHECK-NEXT: Kind: FUNCTION
|
; CHECK-NEXT: Kind: FUNCTION
|
||||||
; CHECK-NEXT: SigIndex: 0
|
; CHECK-NEXT: SigIndex: 0
|
||||||
|
; CHECK-NEXT: - Module: ''
|
||||||
|
; CHECK-NEXT: Field: qux
|
||||||
|
; CHECK-NEXT: Kind: FUNCTION
|
||||||
|
; CHECK-NEXT: SigIndex: 0
|
||||||
|
|
|
@ -5,13 +5,16 @@
|
||||||
target triple = "wasm32-unknown-unknown"
|
target triple = "wasm32-unknown-unknown"
|
||||||
|
|
||||||
declare void @f0() #0
|
declare void @f0() #0
|
||||||
|
declare void @f1() #1
|
||||||
|
|
||||||
define void @_start() {
|
define void @_start() {
|
||||||
call void @f0()
|
call void @f0()
|
||||||
|
call void @f1()
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes #0 = { "wasm-import-module"="somewhere" "wasm-import-name"="something" }
|
attributes #0 = { "wasm-import-module"="somewhere" "wasm-import-name"="something" }
|
||||||
|
attributes #1 = { "wasm-import-module"="otherwhere" "wasm-import-name"="" }
|
||||||
|
|
||||||
; CHECK: - Type: IMPORT
|
; CHECK: - Type: IMPORT
|
||||||
; CHECK-NEXT: Imports:
|
; CHECK-NEXT: Imports:
|
||||||
|
@ -19,9 +22,15 @@ attributes #0 = { "wasm-import-module"="somewhere" "wasm-import-name"="something
|
||||||
; CHECK-NEXT: Field: something
|
; CHECK-NEXT: Field: something
|
||||||
; CHECK-NEXT: Kind: FUNCTION
|
; CHECK-NEXT: Kind: FUNCTION
|
||||||
; CHECK-NEXT: SigIndex: 0
|
; CHECK-NEXT: SigIndex: 0
|
||||||
|
; CHECK-NEXT: - Module: otherwhere
|
||||||
|
; CHECK-NEXT: Field: ''
|
||||||
|
; CHECK-NEXT: Kind: FUNCTION
|
||||||
|
; CHECK-NEXT: SigIndex: 0
|
||||||
|
|
||||||
; CHECK: - Type: CUSTOM
|
; CHECK: - Type: CUSTOM
|
||||||
; CHECK-NEXT: Name: name
|
; CHECK-NEXT: Name: name
|
||||||
; CHECK-NEXT: FunctionNames:
|
; CHECK-NEXT: FunctionNames:
|
||||||
; CHECK-NEXT: - Index: 0
|
; CHECK-NEXT: - Index: 0
|
||||||
; CHECK-NEXT: Name: f0
|
; CHECK-NEXT: Name: f0
|
||||||
|
; CHECK-NEXT: - Index: 1
|
||||||
|
; CHECK-NEXT: Name: f1
|
||||||
|
|
|
@ -640,9 +640,7 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
|
||||||
Info.Name = Import.Field;
|
Info.Name = Import.Field;
|
||||||
}
|
}
|
||||||
Signature = &Signatures[Import.SigIndex];
|
Signature = &Signatures[Import.SigIndex];
|
||||||
if (!Import.Module.empty()) {
|
Info.ImportModule = Import.Module;
|
||||||
Info.ImportModule = Import.Module;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -672,9 +670,7 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
|
||||||
Info.Name = Import.Field;
|
Info.Name = Import.Field;
|
||||||
}
|
}
|
||||||
GlobalType = &Import.Global;
|
GlobalType = &Import.Global;
|
||||||
if (!Import.Module.empty()) {
|
Info.ImportModule = Import.Module;
|
||||||
Info.ImportModule = Import.Module;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -704,9 +700,7 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
|
||||||
Info.Name = Import.Field;
|
Info.Name = Import.Field;
|
||||||
}
|
}
|
||||||
TableType = &Import.Table;
|
TableType = &Import.Table;
|
||||||
if (!Import.Module.empty()) {
|
Info.ImportModule = Import.Module;
|
||||||
Info.ImportModule = Import.Module;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -769,9 +763,7 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
|
||||||
Info.Name = Import.Field;
|
Info.Name = Import.Field;
|
||||||
}
|
}
|
||||||
Signature = &Signatures[Import.SigIndex];
|
Signature = &Signatures[Import.SigIndex];
|
||||||
if (!Import.Module.empty()) {
|
Info.ImportModule = Import.Module;
|
||||||
Info.ImportModule = Import.Module;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue