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

Sameer Sahasrabuddhe via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 8 01:01:34 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))
----------------
ssahasra wrote:

> * (+) Even if we want to avoid combining MMRAs, it's still a well-defined process. We just want to avoid doing it aggressively  (in this case, we want to avoid doing it as part of the IR canonicalization passes such as SimplifyCFG, IC, ...)

In particular, whether an optimization should examine MMRAs is independent of whether it is metadata. Even if MMRAs were an additional operand on the load/store instructions, we still don't want optimizations to merge them.

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


More information about the llvm-commits mailing list