[PATCH] D79530: [lld][WebAssembly] Allow `atomics` feature with unshared memory

Thomas Lively via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 17:38:22 PDT 2020


tlively created this revision.
tlively added reviewers: sbc100, sunfish.
Herald added subscribers: llvm-commits, jfb, aheejin, jgravelle-google, dschuff.
Herald added a project: LLVM.

https://github.com/WebAssembly/threads/issues/144 updated the
WebAssembly threads proposal to make atomic operations on unshared
memories valid. This change updates the feature checking in the linker
accordingly. Production WebAssembly engines have not yet been updated
for this change, so after this change users who accidentally use
atomics with unshared memories will get validation errors at runtime
rather than link errors. This is a small usability regression, but I
think it is warranted because 1) such users are already off the
well-beaten path and 2) as engines do begin to implement this change I
don't want the tools to block experimentation and use of the relaxed
rules.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79530

Files:
  lld/test/wasm/shared-memory.yaml
  lld/wasm/Writer.cpp


Index: lld/wasm/Writer.cpp
===================================================================
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -429,15 +429,6 @@
     for (const auto &key : used.keys())
       allowed.insert(std::string(key));
 
-  if (!config->relocatable && allowed.count("atomics") &&
-      !config->sharedMemory) {
-    if (inferFeatures)
-      error(Twine("'atomics' feature is used by ") + used["atomics"] +
-            ", so --shared-memory must be used");
-    else
-      error("'atomics' feature is used, so --shared-memory must be used");
-  }
-
   if (!config->checkFeatures)
     return;
 
Index: lld/test/wasm/shared-memory.yaml
===================================================================
--- lld/test/wasm/shared-memory.yaml
+++ lld/test/wasm/shared-memory.yaml
@@ -8,8 +8,6 @@
 
 # RUN: not wasm-ld --no-entry --shared-memory --max-memory=131072 --features=atomics %t1.o -o - 2>&1 | FileCheck %s --check-prefix SHARED-NO-BULK-MEM
 
-# RUN: not wasm-ld --no-entry --features=atomics %t1.o -o - 2>&1 | FileCheck %s --check-prefix ATOMICS-NO-SHARED
-
 # RUN: wasm-ld --relocatable --features=atomics %t1.o -o - | obj2yaml | FileCheck %s --check-prefix ATOMICS-RELOCATABLE
 
 # RUN: wasm-ld --no-entry --shared-memory --max-memory=131072 --features=atomics,bulk-memory %t1.o -o - | obj2yaml | FileCheck %s --check-prefix SHARED
@@ -65,8 +63,6 @@
 
 # SHARED-NO-BULK-MEM: 'bulk-memory' feature must be used in order to use shared memory
 
-# ATOMICS-NO-SHARED: 'atomics' feature is used, so --shared-memory must be used{{$}}
-
 # ATOMICS-RELOCATABLE:        - Type:            MEMORY
 # ATOMICS-RELOCATABLE-NEXT:     Memories:
 # ATOMICS-RELOCATABLE-NEXT:         Initial:         0x00000001


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79530.262505.patch
Type: text/x-patch
Size: 1733 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200507/1f3148e9/attachment.bin>


More information about the llvm-commits mailing list