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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 11 08:03:05 PDT 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))
----------------
nikic wrote:

> If the amount of pass changes is going to be a blocker I'm open to taking a less conservative approach and just leave the Transform changes that I can prove actively hurt MMRAs (so if I have real-world evidence that that pass caused problems). IIRC that'd only leave SimplifyCFG but I'd need to run more tests. I can then make more changes over time if needed. Would that be better?

Yes, that would be better. I think your fence example for SimplifyCFG is compelling, but I'm still doubtful about other changes you've made (esp. when it comes to CSE-like transforms).

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


More information about the llvm-commits mailing list