[llvm] [SPARC] Weaken emitted barriers for atomic ops (PR #154950)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 26 11:26:14 PDT 2025


================
@@ -653,6 +653,22 @@ bool SparcInstrInfo::expandPostRAPseudo(MachineInstr &MI) const {
         .addImm(Offset);
     return true;
   }
+  case SP::V8BAR: {
+    assert(!Subtarget.isV9() &&
+           "V8BAR should not be emitted on V9 processors!");
+
+    // Emit stbar; ldstub [%sp-1], %g0
+    // The sequence acts as a full barrier on V8 systems.
+    MachineBasicBlock &MBB = *MI.getParent();
+    MachineInstr &InstSTBAR =
+        *BuildMI(MBB, MI, MI.getDebugLoc(), get(SP::STBAR));
+    MachineInstr &InstLDSTUB =
+        *BuildMI(MBB, MI, MI.getDebugLoc(), get(SP::LDSTUBri), SP::G0)
+             .addReg(SP::O6)
+             .addImm(-1);
+    MIBundleBuilder(MBB, InstSTBAR, InstLDSTUB);
----------------
koachan wrote:

Hmm, I dunno what do you mean by MC lowering here, sorry
In my understanding after doing `finalizeBundle` the `stbar; ldstub` sequence will be prefixed by a `BUNDLE` instruction, but then a later pass ought to remove the `BUNDLE` prefix right?

https://github.com/llvm/llvm-project/pull/154950


More information about the llvm-commits mailing list