[PATCH] D57874: [WebAssembly] Set '-matomics' when '-pthread' is set

Heejin Ahn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 6 19:37:03 PST 2019


aheejin updated this revision to Diff 185700.
aheejin added a comment.

- Small fix


Repository:
  rC Clang

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

https://reviews.llvm.org/D57874

Files:
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/wasm32-unknown-unknown.cpp
  test/Driver/wasm64-unknown-unknown.cpp


Index: test/Driver/wasm64-unknown-unknown.cpp
===================================================================
--- test/Driver/wasm64-unknown-unknown.cpp
+++ test/Driver/wasm64-unknown-unknown.cpp
@@ -120,3 +120,6 @@
   // CHECK: SwitchILi8
   Switch<sizeof(va_list)>();
 }
+
+// -pthread turns on -matomics
+// THREADS: attributes #{{[[0-9]+}} = {{{.*}}"target-features"="+atomics"{{.*}}}
Index: test/Driver/wasm32-unknown-unknown.cpp
===================================================================
--- test/Driver/wasm32-unknown-unknown.cpp
+++ test/Driver/wasm32-unknown-unknown.cpp
@@ -120,3 +120,6 @@
   // CHECK: SwitchILi4
   Switch<sizeof(va_list)>();
 }
+
+// -pthread turns on -matomics
+// THREADS: attributes #{{[[0-9]+}} = {{{.*}}"target-features"="+atomics"{{.*}}}
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -3332,6 +3332,11 @@
     Res.getDiagnosticOpts().Warnings.push_back("spir-compat");
   }
 
+  if (Arch == llvm::Triple::wasm32 || Arch == llvm::Triple::wasm64) {
+    if (LangOpts.POSIXThreads)
+      Res.getTargetOpts().FeaturesAsWritten.emplace_back("+atomics");
+  }
+
   // If sanitizer is enabled, disable OPT_ffine_grained_bitfield_accesses.
   if (Res.getCodeGenOpts().FineGrainedBitfieldAccesses &&
       !Res.getLangOpts()->Sanitize.empty()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57874.185700.patch
Type: text/x-patch
Size: 1434 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190207/dbf10609/attachment.bin>


More information about the cfe-commits mailing list