[PATCH] D48689: [WebAssembly] Set threadmodel during LTO

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 28 10:24:35 PDT 2018


sbc100 updated this revision to Diff 153348.
sbc100 added a comment.

- add test


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D48689

Files:
  test/wasm/lto/atomics.ll
  wasm/LTO.cpp


Index: wasm/LTO.cpp
===================================================================
--- wasm/LTO.cpp
+++ wasm/LTO.cpp
@@ -45,10 +45,13 @@
   lto::Config C;
   C.Options = InitTargetOptionsFromCodeGenFlags();
 
-  // Always emit a section per function/datum with LTO.
+  // Always emit a section per function/data with LTO.
   C.Options.FunctionSections = true;
   C.Options.DataSections = true;
 
+  // Wasm currently only supports ThreadModel::Single
+  C.Options.ThreadModel = ThreadModel::Single;
+
   C.DisableVerify = Config->DisableVerify;
   C.DiagHandler = diagnosticHandler;
   C.OptLevel = Config->LTOO;
Index: test/wasm/lto/atomics.ll
===================================================================
--- /dev/null
+++ test/wasm/lto/atomics.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-as %s -o %t.o
+; RUN: wasm-ld %t.o -o %t.wasm -lto-O0
+; Atomic operations with fail to compile if the ThreadModel is not
+; correctly set to Single (i.e. if atomics are not lowered to regular ops).
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown-wasm"
+
+ at foo = hidden global i32 1
+
+define void @_start() {
+  %1 = load atomic i32, i32* @foo unordered, align 4
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48689.153348.patch
Type: text/x-patch
Size: 1221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180628/ec3f91b7/attachment.bin>


More information about the llvm-commits mailing list