[llvm-branch-commits] [cfe-branch] r314464 - Merging r312651:

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Sep 28 14:57:44 PDT 2017


Author: tstellar
Date: Thu Sep 28 14:57:43 2017
New Revision: 314464

URL: http://llvm.org/viewvc/llvm-project?rev=314464&view=rev
Log:
Merging r312651:

------------------------------------------------------------------------
r312651 | jroelofs | 2017-09-06 10:09:25 -0700 (Wed, 06 Sep 2017) | 23 lines

Fix ARM bare metal driver to support atomics

The new bare metal support only supports the single thread model. This causes
the builtin atomic functions (e.g.: __atomic_fetch_add) to not generate
thread-safe assembly for these operations, which breaks our firmware. We target
bare metal, and need to atomically modify variables in our interrupt routines,
and task threads.

Internally, the -mthread-model flag determines whether to lower or expand
atomic operations (see D4984).

This change removes the overridden thread model methods, and instead relies on
the base ToolChain class to validate the thread model (which already includes
logic to validate single thread model support). If the single thread model is
required, the -mthread-model flag will have to be provided.

As a workaround "-mthread-model posix" could be provided, but it only works due
to a bug in the validation of the -mthread-model flag (separate patch coming to
fix this).

https://reviews.llvm.org/D37493

Patch by: Ian Tessier!
------------------------------------------------------------------------

Modified:
    cfe/branches/release_50/lib/Driver/ToolChains/BareMetal.cpp
    cfe/branches/release_50/lib/Driver/ToolChains/BareMetal.h
    cfe/branches/release_50/test/Driver/baremetal.cpp

Modified: cfe/branches/release_50/lib/Driver/ToolChains/BareMetal.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChains/BareMetal.cpp?rev=314464&r1=314463&r2=314464&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChains/BareMetal.cpp (original)
+++ cfe/branches/release_50/lib/Driver/ToolChains/BareMetal.cpp Thu Sep 28 14:57:43 2017
@@ -65,14 +65,6 @@ Tool *BareMetal::buildLinker() const {
   return new tools::baremetal::Linker(*this);
 }
 
-std::string BareMetal::getThreadModel() const {
-  return "single";
-}
-
-bool BareMetal::isThreadModelSupported(const StringRef Model) const {
-  return Model == "single";
-}
-
 std::string BareMetal::getRuntimesDir() const {
   SmallString<128> Dir(getDriver().ResourceDir);
   llvm::sys::path::append(Dir, "lib", "baremetal");

Modified: cfe/branches/release_50/lib/Driver/ToolChains/BareMetal.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChains/BareMetal.h?rev=314464&r1=314463&r2=314464&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChains/BareMetal.h (original)
+++ cfe/branches/release_50/lib/Driver/ToolChains/BareMetal.h Thu Sep 28 14:57:43 2017
@@ -38,8 +38,6 @@ public:
   bool isPICDefaultForced() const override { return false; }
   bool SupportsProfiling() const override { return false; }
   bool SupportsObjCGC() const override { return false; }
-  std::string getThreadModel() const override;
-  bool isThreadModelSupported(const StringRef Model) const override;
 
   RuntimeLibType GetDefaultRuntimeLibType() const override {
     return ToolChain::RLT_CompilerRT;

Modified: cfe/branches/release_50/test/Driver/baremetal.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/test/Driver/baremetal.cpp?rev=314464&r1=314463&r2=314464&view=diff
==============================================================================
--- cfe/branches/release_50/test/Driver/baremetal.cpp (original)
+++ cfe/branches/release_50/test/Driver/baremetal.cpp Thu Sep 28 14:57:43 2017
@@ -74,4 +74,12 @@
 
 // RUN: %clangxx -target arm-none-eabi -v 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-THREAD-MODEL
-// CHECK-THREAD-MODEL: Thread model: single
+// CHECK-THREAD-MODEL: Thread model: posix
+
+// RUN: %clangxx -target arm-none-eabi -mthread-model single -v 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-THREAD-MODEL-SINGLE
+// CHECK-THREAD-MODEL-SINGLE: Thread model: single
+
+// RUN: %clangxx -target arm-none-eabi -mthread-model posix -v 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-THREAD-MODEL-POSIX
+// CHECK-THREAD-MODEL-POSIX: Thread model: posix




More information about the llvm-branch-commits mailing list