[llvm] [RFC] Memory Model Relaxation Annotations (PR #78569)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 7 23:35:53 PST 2024


================
@@ -698,6 +700,16 @@ bool Instruction::hasSameSpecialState(const Instruction *I2,
   assert(I1->getOpcode() == I2->getOpcode() &&
          "Can not compare special state of different instructions");
 
+  // MMRAs may change semantics of an operation, e.g. make a fence only
+  // affect a given address space.
+  //
+  // FIXME: Not sure if this stinks or not. Maybe we should just look at
+  // all callers and make them check MMRAs.
+  // OTOH, MMRAs can really alter semantics so this is technically correct
+  // (the best kind of correct).
+  if (MMRAMetadata(*this) != MMRAMetadata(*I2))
----------------
Pierre-vh wrote:

@nikic as @ssahasra said, we want to start by making pass treat MMRAs very conservatively, and avoid losing/combining them as much as possible. Over time we may loosen this up and allow for more merging once our toolchain uses MMRAs and we have more performance data to work with.

I implemented this restriction per-pass now (each pass checks MMRAs). I don't think we have that many passes that can merge memory/synchronizing instructions so I hope I covered most of them, is there any that are missing?
(note: GVN is still missing, I have to figure out how to handle that one)

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


More information about the llvm-commits mailing list