diff --git a/clang/lib/Basic/Targets/WebAssembly.h b/clang/lib/Basic/Targets/WebAssembly.h --- a/clang/lib/Basic/Targets/WebAssembly.h +++ b/clang/lib/Basic/Targets/WebAssembly.h @@ -30,7 +30,7 @@ UnimplementedSIMD128, } SIMDLevel = NoSIMD; - bool HasNontrappingFPToInt = true; + bool HasNontrappingFPToInt = false; bool HasSignExt = false; bool HasExceptionHandling = false; bool HasBulkMemory = false; diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp --- a/clang/lib/Basic/Targets/WebAssembly.cpp +++ b/clang/lib/Basic/Targets/WebAssembly.cpp @@ -112,11 +112,12 @@ bool WebAssemblyTargetInfo::initFeatureMap( llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector &FeaturesVec) const { - if (CPU == "mvp") { - Features["nontrapping-fptoint"] = false; + if (CPU == "generic") { + Features["nontrapping-fptoint"] = true; } if (CPU == "bleeding-edge") { + Features["nontrapping-fptoint"] = true; Features["sign-ext"] = true; Features["bulk-memory"] = true; Features["atomics"] = true; @@ -129,8 +130,8 @@ // are actively developing new features it is useful to let user-configured // features control availability of builtins setSIMDLevel(Features, SIMDLevel); - if (!HasNontrappingFPToInt) - Features["nontrapping-fptoint"] = false; + if (HasNontrappingFPToInt) + Features["nontrapping-fptoint"] = true; if (HasSignExt) Features["sign-ext"] = true; if (HasExceptionHandling) diff --git a/clang/test/Preprocessor/wasm-target-features.c b/clang/test/Preprocessor/wasm-target-features.c --- a/clang/test/Preprocessor/wasm-target-features.c +++ b/clang/test/Preprocessor/wasm-target-features.c @@ -7,8 +7,6 @@ // DEFAULT:#define __wasm_nontrapping_fptoint__ 1{{$}} -// NONTRAPPING-FPTOINT:#define __wasm_nontrapping_fptoint__ 1{{$}} - // RUN: %clang -E -dM %s -o - 2>&1 \ // RUN: -target wasm32-unknown-unknown -msimd128 \ // RUN: | FileCheck %s -check-prefix=SIMD128 diff --git a/lld/test/wasm/alias.ll b/lld/test/wasm/alias.ll --- a/lld/test/wasm/alias.ll +++ b/lld/test/wasm/alias.ll @@ -62,3 +62,5 @@ ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Name: _start +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: target_features diff --git a/lld/test/wasm/call-indirect.ll b/lld/test/wasm/call-indirect.ll --- a/lld/test/wasm/call-indirect.ll +++ b/lld/test/wasm/call-indirect.ll @@ -154,3 +154,5 @@ ; CHECK-NEXT: Name: _start ; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Name: call_ptr +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: target_features diff --git a/lld/test/wasm/cxx-mangling.ll b/lld/test/wasm/cxx-mangling.ll --- a/lld/test/wasm/cxx-mangling.ll +++ b/lld/test/wasm/cxx-mangling.ll @@ -54,3 +54,5 @@ ; MANGLE-NEXT: Name: _Z3fooi ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: _start +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: target_features diff --git a/lld/test/wasm/data-layout.ll b/lld/test/wasm/data-layout.ll --- a/lld/test/wasm/data-layout.ll +++ b/lld/test/wasm/data-layout.ll @@ -1,5 +1,5 @@ -; RUN: llc -filetype=obj %p/Inputs/hello.ll -o %t.hello.o -; RUN: llc -filetype=obj %s -o %t.o +; RUN: llc -mcpu=mvp -filetype=obj %p/Inputs/hello.ll -o %t.hello.o +; RUN: llc -mcpu=mvp -filetype=obj %s -o %t.o target triple = "wasm32-unknown-unknown" @@ -69,7 +69,7 @@ ; CHECK-MAX-NEXT: Maximum: 0x00000002 ; RUN: wasm-ld -no-gc-sections --allow-undefined --no-entry --shared-memory \ -; RUN: --features=atomics,bulk-memory,nontrapping-fptoint --initial-memory=131072 \ +; RUN: --features=atomics,bulk-memory --initial-memory=131072 \ ; RUN: --max-memory=131072 -o %t_max.wasm %t.o %t.hello.o ; RUN: obj2yaml %t_max.wasm | FileCheck %s -check-prefix=CHECK-SHARED diff --git a/lld/test/wasm/import-memory.test b/lld/test/wasm/import-memory.test --- a/lld/test/wasm/import-memory.test +++ b/lld/test/wasm/import-memory.test @@ -1,4 +1,4 @@ -# RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.start.o +# RUN: llc -mcpu=mvp -filetype=obj %p/Inputs/start.ll -o %t.start.o # RUN: wasm-ld --import-memory -o %t.wasm %t.start.o # RUN: obj2yaml %t.wasm | FileCheck %s @@ -32,8 +32,7 @@ # CHECK-MAX-NEXT: Maximum: 0x00000005 # CHECK-MAX-NEXT: - Type: -# RUN: wasm-ld --import-memory --shared-memory \ -# RUN: --features=nontrapping-fptoint,atomics,bulk-memory \ +# RUN: wasm-ld --import-memory --shared-memory --features=atomics,bulk-memory \ # RUN: --initial-memory=262144 --max-memory=327680 -o %t.max.wasm %t.start.o # RUN: obj2yaml %t.max.wasm | FileCheck -check-prefix=CHECK-SHARED %s diff --git a/llvm/test/CodeGen/WebAssembly/multivalue.ll b/llvm/test/CodeGen/WebAssembly/multivalue.ll --- a/llvm/test/CodeGen/WebAssembly/multivalue.ll +++ b/llvm/test/CodeGen/WebAssembly/multivalue.ll @@ -1,5 +1,5 @@ -; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -mattr=+multivalue,+tail-call | FileCheck %s -; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+multivalue,+tail-call | FileCheck %s --check-prefix REGS +; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -mcpu=mvp -mattr=+multivalue,+tail-call | FileCheck %s +; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -mcpu=mvp -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+multivalue,+tail-call | FileCheck %s --check-prefix REGS ; RUN: llc < %s --filetype=obj -mattr=+multivalue,+tail-call | obj2yaml | FileCheck %s --check-prefix OBJ ; Test that the multivalue calls, returns, function types, and block @@ -249,14 +249,11 @@ } ; CHECK-LABEL: .section .custom_section.target_features -; CHECK-NEXT: .int8 3 +; CHECK-NEXT: .int8 2 ; CHECK-NEXT: .int8 43 ; CHECK-NEXT: .int8 10 ; CHECK-NEXT: .ascii "multivalue" ; CHECK-NEXT: .int8 43 -; CHECK-NEXT: .int8 19 -; CHECK-NEXT: .ascii "nontrapping-fptoint" -; CHECK-NEXT: .int8 43 ; CHECK-NEXT: .int8 9 ; CHECK-NEXT: .ascii "tail-call"