[llvm-branch-commits] [llvm] release/19.x: [WebAssembly] Fix feature coalescing (#110647) (PR #112431)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Oct 15 13:15:30 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-webassembly

Author: None (llvmbot)

<details>
<summary>Changes</summary>

Backport 5a7b79c93e2e0c71aec016973f5f13d3bb2e7a62

Requested by: @<!-- -->nikic

---
Full diff: https://github.com/llvm/llvm-project/pull/112431.diff


1 Files Affected:

- (modified) llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp (+4-8) 


``````````diff
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index 23539a5f4b26f1..ac9e6d5a90cb3c 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -202,8 +202,7 @@ class CoalesceFeaturesAndStripAtomics final : public ModulePass {
   bool runOnModule(Module &M) override {
     FeatureBitset Features = coalesceFeatures(M);
 
-    std::string FeatureStr =
-        getFeatureString(Features, WasmTM->getTargetFeatureString());
+    std::string FeatureStr = getFeatureString(Features);
     WasmTM->setTargetFeatureString(FeatureStr);
     for (auto &F : M)
       replaceFeatures(F, FeatureStr);
@@ -241,17 +240,14 @@ class CoalesceFeaturesAndStripAtomics final : public ModulePass {
     return Features;
   }
 
-  static std::string getFeatureString(const FeatureBitset &Features,
-                                      StringRef TargetFS) {
+  static std::string getFeatureString(const FeatureBitset &Features) {
     std::string Ret;
     for (const SubtargetFeatureKV &KV : WebAssemblyFeatureKV) {
       if (Features[KV.Value])
         Ret += (StringRef("+") + KV.Key + ",").str();
+      else
+        Ret += (StringRef("-") + KV.Key + ",").str();
     }
-    SubtargetFeatures TF{TargetFS};
-    for (std::string const &F : TF.getFeatures())
-      if (!SubtargetFeatures::isEnabled(F))
-        Ret += F + ",";
     return Ret;
   }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/112431


More information about the llvm-branch-commits mailing list