aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
diff options
context:
space:
mode:
authorDan Gohman <dev@sunfishcode.online>2024-10-25 13:52:51 -0700
committerGitHub <noreply@github.com>2024-10-25 13:52:51 -0700
commit1bc2cd98c58a1059170dc38697c7a29a8e21160b (patch)
treebe5d16e4d56862ddbaabb1fca86f8e62e912816a /llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
parentcfde4fbccf5d8d949a8cade0a4f8ef9b0f47ca73 (diff)
downloadllvm-1bc2cd98c58a1059170dc38697c7a29a8e21160b.zip
llvm-1bc2cd98c58a1059170dc38697c7a29a8e21160b.tar.gz
llvm-1bc2cd98c58a1059170dc38697c7a29a8e21160b.tar.bz2
[WebAssembly] Enable nontrapping-fptoint and bulk-memory by default. (#112049)
We were prepared to enable these features [back in February], but they got pulled for what appear to be unrelated reasons. So let's have another try at enabling them! Another motivation here is that it'd be convenient for the [Lime1 proposal] if "lime1" is close to a subset of "generic" (missing only for extended-const). [back in February]: https://github.com/WebAssembly/tool-conventions/issues/158#issuecomment-1931119512 [Lime1 proposal]: https://github.com/llvm/llvm-project/pull/112035
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index 3fe6ccf..83cd57d 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -233,13 +233,30 @@ public:
private:
FeatureBitset coalesceFeatures(const Module &M) {
- FeatureBitset Features =
- WasmTM
- ->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
- std::string(WasmTM->getTargetFeatureString()))
- ->getFeatureBits();
- for (auto &F : M)
+ // Union the features of all defined functions. Start with an empty set, so
+ // that if a feature is disabled in every function, we'll compute it as
+ // disabled. If any function lacks a target-features attribute, it'll
+ // default to the target CPU from the `TargetMachine`.
+ FeatureBitset Features;
+ bool AnyDefinedFuncs = false;
+ for (auto &F : M) {
+ if (F.isDeclaration())
+ continue;
+
Features |= WasmTM->getSubtargetImpl(F)->getFeatureBits();
+ AnyDefinedFuncs = true;
+ }
+
+ // If we have no defined functions, use the target CPU from the
+ // `TargetMachine`.
+ if (!AnyDefinedFuncs) {
+ Features =
+ WasmTM
+ ->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
+ std::string(WasmTM->getTargetFeatureString()))
+ ->getFeatureBits();
+ }
+
return Features;
}