[PATCH] D78072: [lld][WebAssembly] Do not require --shared-memory with --relocatable

Thomas Lively via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 14:06:19 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG6474d1b20ea7: [lld][WebAssembly] Do not require --shared-memory with --relocatable (authored by tlively).

Changed prior to commit:
  https://reviews.llvm.org/D78072?vs=257443&id=257494#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78072/new/

https://reviews.llvm.org/D78072

Files:
  lld/test/wasm/driver.ll
  lld/test/wasm/relocatable.ll
  lld/test/wasm/shared-memory.yaml
  lld/wasm/Driver.cpp
  lld/wasm/Writer.cpp


Index: lld/wasm/Writer.cpp
===================================================================
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -429,7 +429,8 @@
     for (const auto &key : used.keys())
       allowed.insert(std::string(key));
 
-  if (allowed.count("atomics") && !config->sharedMemory) {
+  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");
Index: lld/wasm/Driver.cpp
===================================================================
--- lld/wasm/Driver.cpp
+++ lld/wasm/Driver.cpp
@@ -453,6 +453,8 @@
       error("-r -and --undefined may not be used together");
     if (config->pie)
       error("-r and -pie may not be used together");
+    if (config->sharedMemory)
+      error("-r and --shared-memory may not be used together");
   }
 }
 
Index: lld/test/wasm/shared-memory.yaml
===================================================================
--- lld/test/wasm/shared-memory.yaml
+++ lld/test/wasm/shared-memory.yaml
@@ -10,6 +10,8 @@
 
 # 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
 
 --- !WASM
@@ -65,6 +67,11 @@
 
 # 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
+# ATOMICS-RELOCATABLE-NEXT:   - Type:
+
 # SHARED:        - Type:            MEMORY
 # SHARED-NEXT:     Memories:
 # SHARED-NEXT:       - Flags:           [ HAS_MAX, IS_SHARED ]
Index: lld/test/wasm/relocatable.ll
===================================================================
--- lld/test/wasm/relocatable.ll
+++ lld/test/wasm/relocatable.ll
@@ -1,12 +1,7 @@
 ; RUN: llc -filetype=obj %p/Inputs/hello.ll -o %t.hello.o
 ; RUN: llc -filetype=obj %s -o %t.o
 ; RUN: wasm-ld -r -o %t.wasm %t.hello.o %t.o
-; RUN: obj2yaml %t.wasm | FileCheck %s --check-prefixes CHECK,NORMAL
-
-; RUN: llc -filetype=obj %p/Inputs/hello.ll -o %t.hello.bm.o -mattr=+bulk-memory,+atomics
-; RUN: llc -filetype=obj %s -o %t.bm.o -mattr=+bulk-memory
-; RUN: wasm-ld -r -o %t.mt.wasm %t.hello.bm.o %t.bm.o --shared-memory --max-memory=131072
-; RUN: obj2yaml %t.mt.wasm | FileCheck %s --check-prefixes CHECK,SHARED
+; RUN: obj2yaml %t.wasm | FileCheck %s
 
 target triple = "wasm32-unknown-unknown"
 
@@ -79,10 +74,7 @@
 ; CHECK-NEXT:           Maximum:         0x00000004
 ; CHECK-NEXT:   - Type:            MEMORY
 ; CHECK-NEXT:     Memories:
-; NORMAL-NEXT:      - Initial:         0x00000001
-; SHARED-NEXT:      - Flags:           [ HAS_MAX, IS_SHARED ]
-; SHARED-NEXT:        Initial:         0x00000001
-; SHARED-NEXT:        Maximum:         0x00000002
+; CHECK-NEXT:      - Initial:         0x00000001
 ; CHECK-NEXT:   - Type:            ELEM
 ; CHECK-NEXT:     Segments:
 ; CHECK-NEXT:       - Offset:
Index: lld/test/wasm/driver.ll
===================================================================
--- lld/test/wasm/driver.ll
+++ lld/test/wasm/driver.ll
@@ -20,3 +20,7 @@
 ; RUN: not wasm-ld --export-table --import-table %t.o 2>&1 \
 ; RUN:   | FileCheck -check-prefix=TABLE %s
 ; TABLE: error: --import-table and --export-table may not be used together
+
+; RUN: not wasm-ld --relocatable --shared-memory %t.o 2>&1 \
+; RUN:   | FileCheck -check-prefix=SHARED-MEM %s
+; SHARED-MEM: error: -r and --shared-memory may not be used together


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78072.257494.patch
Type: text/x-patch
Size: 3865 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200414/56d593e5/attachment.bin>


More information about the llvm-commits mailing list