From: Sam Clegg Date: Wed, 5 Jul 2017 20:09:26 +0000 (+0000) Subject: [WebAssembly] MC: Don't generate extra types for weak alias X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a6a29d93c80f7c7ae96a01a721d8534945656df6;p=llvm [WebAssembly] MC: Don't generate extra types for weak alias Previously we were generating a void(void) function type for a weak alias. Update the weak-alias test case to catch this. Differential Revision: https://reviews.llvm.org/D34734 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307194 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/BinaryFormat/Wasm.h b/include/llvm/BinaryFormat/Wasm.h index eef473b20dd..4cb373a0b70 100644 --- a/include/llvm/BinaryFormat/Wasm.h +++ b/include/llvm/BinaryFormat/Wasm.h @@ -107,7 +107,7 @@ struct WasmElemSegment { struct WasmRelocation { uint32_t Type; // The type of the relocation. - int32_t Index; // Index into function to global index space. + uint32_t Index; // Index into function to global index space. uint64_t Offset; // Offset from the start of the section. int64_t Addend; // A value to add to the symbol. }; diff --git a/lib/MC/WasmObjectWriter.cpp b/lib/MC/WasmObjectWriter.cpp index 82352cb50c7..426f7e1bd9a 100644 --- a/lib/MC/WasmObjectWriter.cpp +++ b/lib/MC/WasmObjectWriter.cpp @@ -959,6 +959,10 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm, // Populate the Imports set. for (const MCSymbol &S : Asm.symbols()) { + // Weak aliases don't have thier own function types. + if (S.isVariable()) + continue; + const auto &WS = static_cast(S); int32_t Type; diff --git a/test/MC/WebAssembly/weak-alias.ll b/test/MC/WebAssembly/weak-alias.ll index 6e2b8631d2b..d870e88cb69 100644 --- a/test/MC/WebAssembly/weak-alias.ll +++ b/test/MC/WebAssembly/weak-alias.ll @@ -10,6 +10,14 @@ entry: ret i32 0 } +; CHECK: - Type: TYPE +; CHECK-NEXT: Signatures: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Type: FUNCTION +; CHECK-NEXT: FunctionTypes: [ 0 ] + ; CHECK: - Type: EXPORT ; CHECK-NEXT: Exports: ; CHECK-NEXT: - Name: foo @@ -19,7 +27,6 @@ entry: ; CHECK-NEXT: Kind: FUNCTION ; CHECK-NEXT: Index: 0 - ; CHECK: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: