Index: llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp =================================================================== --- llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp +++ llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp @@ -499,6 +499,15 @@ // This pseudo-feature tells the linker whether shared memory would be safe EmitFeature("shared-mem"); + // This is an "architecture", not a "feature", but we emit it as such for + // the benefit of tools like Binaryen and consistency with other producers. + // FIXME: Subtarget is null here, so can't Subtarget->hasAddr64() ? + if (M.getDataLayout().getMaxPointerSize() == 8) { + // Can't use EmitFeature since "wasm-feature-memory64" is not a module + // flag. + EmittedFeatures.push_back({wasm::WASM_FEATURE_PREFIX_USED, "memory64"}); + } + if (EmittedFeatures.size() == 0) return; Index: llvm/test/CodeGen/WebAssembly/memory64-feature.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/WebAssembly/memory64-feature.ll @@ -0,0 +1,15 @@ +; RUN: llc < %s | FileCheck %s + +; Test that wasm64 is properly emitted into the target features section + +target triple = "wasm64-unknown-unknown" + +define void @foo() { + ret void +} + +; CHECK-LABEL: .custom_section.target_features +; CHECK-NEXT: .int8 1 +; CHECK-NEXT: .int8 43 +; CHECK-NEXT: .int8 8 +; CHECK-NEXT: .ascii "memory64" Index: llvm/test/MC/WebAssembly/debug-info64.ll =================================================================== --- llvm/test/MC/WebAssembly/debug-info64.ll +++ llvm/test/MC/WebAssembly/debug-info64.ll @@ -129,6 +129,12 @@ ; CHECK-NEXT: Offset: 1073 ; CHECK-NEXT: Name: producers ; CHECK-NEXT: } +; CHECK-NEXT: Section { +; CHECK-NEXT: Type: CUSTOM (0x0) +; CHECK-NEXT: Size: 11 +; CHECK-NEXT: Offset: 1166 +; CHECK-NEXT: Name: target_features +; CHECK-NEXT: } ; CHECK-NEXT: ] ; CHECK-NEXT: Relocations [ ; CHECK-NEXT: Section (7) DATA {