ARM: Use "dmb sy" for barriers on M-class CPUs
authorTim Northover <tnorthover@apple.com>
Wed, 28 Aug 2013 14:39:19 +0000 (14:39 +0000)
committerTim Northover <tnorthover@apple.com>
Wed, 28 Aug 2013 14:39:19 +0000 (14:39 +0000)
The usual default of "dmb ish" (inner-shareable) isn't even a valid instruction
on v6M or v7M (well, it does the same thing but software is strongly
discouraged from using it) so we should emit a full-system barrier there.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189483 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMISelLowering.cpp
test/CodeGen/Thumb/barrier.ll

index 74353c1788a5c231d6b0167b37465baadf6482a5..063f1d46c7dc57a2c6cfdf9902ba25ac30e2fd6a 100644 (file)
@@ -2600,7 +2600,10 @@ static SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG &DAG,
   ConstantSDNode *OrdN = cast<ConstantSDNode>(Op.getOperand(1));
   AtomicOrdering Ord = static_cast<AtomicOrdering>(OrdN->getZExtValue());
   unsigned Domain = ARM_MB::ISH;
-  if (Subtarget->isSwift() && Ord == Release) {
+  if (Subtarget->isMClass()) {
+    // Only a full system barrier exists in the M-class architectures.
+    Domain = ARM_MB::SY;
+  } else if (Subtarget->isSwift() && Ord == Release) {
     // Swift happens to implement ISHST barriers in a way that's compatible with
     // Release semantics but weaker than ISH so we'd be fools not to use
     // it. Beware: other processors probably don't!
index 8fca273cc238529e6d4ea70261c677a2a3c27325..1c27fa09884f6c2a43ec237e0d6532210f865609 100644 (file)
@@ -7,7 +7,7 @@ define void @t1() {
 ; V6: blx {{_*}}sync_synchronize
 
 ; V6M-LABEL: t1:
-; V6M: dmb ish
+; V6M: dmb sy
   fence seq_cst
   ret void
 }