[llvm] [RFC] Memory Model Relaxation Annotations (PR #78569)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 21 05:50:10 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))
----------------
nikic wrote:
The way you are approaching this, you can't *really* drop MMRAs. Like, yes, it's semantically correct to do, but it sounds like every time it would happen in a generic transform, you would actually treat that like a bug and slap an extra MMRA check in that transform. You are actively fighting the metadata model at every step here.
I'm not sure to what degree all these checks you have introduced are *actually* necessary, as opposed to you being overly conservative. For example, is `if (x) { load p, !mmra1 } else { load p, !mmra2 }` really something that you expect to happen a lot in practice? But if these are necessary, then I don't think this is the right mechanism.
https://github.com/llvm/llvm-project/pull/78569
More information about the llvm-commits
mailing list