diff --git a/lld/test/wasm/import-module.ll b/lld/test/wasm/import-module.ll --- a/lld/test/wasm/import-module.ll +++ b/lld/test/wasm/import-module.ll @@ -6,12 +6,15 @@ define void @_start() { call void @foo(); + call void @qux(); ret void } declare void @foo() #0 +declare void @qux() #1 attributes #0 = { "wasm-import-module"="bar" } +attributes #1 = { "wasm-import-module"="" } ; CHECK: - Type: IMPORT ; CHECK-NEXT: Imports: @@ -19,3 +22,7 @@ ; CHECK-NEXT: Field: foo ; CHECK-NEXT: Kind: FUNCTION ; CHECK-NEXT: SigIndex: 0 +; CHECK-NEXT: - Module: '' +; CHECK-NEXT: Field: qux +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: SigIndex: 0 diff --git a/lld/test/wasm/import-name.ll b/lld/test/wasm/import-name.ll --- a/lld/test/wasm/import-name.ll +++ b/lld/test/wasm/import-name.ll @@ -5,13 +5,16 @@ target triple = "wasm32-unknown-unknown" declare void @f0() #0 +declare void @f1() #1 define void @_start() { call void @f0() + call void @f1() ret void } attributes #0 = { "wasm-import-module"="somewhere" "wasm-import-name"="something" } +attributes #1 = { "wasm-import-module"="otherwhere" "wasm-import-name"="" } ; CHECK: - Type: IMPORT ; CHECK-NEXT: Imports: @@ -19,9 +22,15 @@ ; CHECK-NEXT: Field: something ; CHECK-NEXT: Kind: FUNCTION ; CHECK-NEXT: SigIndex: 0 +; CHECK-NEXT: - Module: otherwhere +; CHECK-NEXT: Field: '' +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: SigIndex: 0 ; CHECK: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Name: f0 +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: Name: f1 diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -640,9 +640,7 @@ Info.Name = Import.Field; } Signature = &Signatures[Import.SigIndex]; - if (!Import.Module.empty()) { - Info.ImportModule = Import.Module; - } + Info.ImportModule = Import.Module; } break; @@ -672,9 +670,7 @@ Info.Name = Import.Field; } GlobalType = &Import.Global; - if (!Import.Module.empty()) { - Info.ImportModule = Import.Module; - } + Info.ImportModule = Import.Module; } break; @@ -704,9 +700,7 @@ Info.Name = Import.Field; } TableType = &Import.Table; - if (!Import.Module.empty()) { - Info.ImportModule = Import.Module; - } + Info.ImportModule = Import.Module; } break; @@ -769,9 +763,7 @@ Info.Name = Import.Field; } Signature = &Signatures[Import.SigIndex]; - if (!Import.Module.empty()) { - Info.ImportModule = Import.Module; - } + Info.ImportModule = Import.Module; } break; }