[Mlir-commits] [llvm] [mlir] [IR][ModRef] Introduce `errno` memory location (PR #120783)
Nikita Popov
llvmlistbot at llvm.org
Wed Feb 12 12:34:59 PST 2025
================
@@ -2398,9 +2397,25 @@ Error BitcodeReader::parseAttributeGroupBlock() {
B.addUWTableAttr(UWTableKind(Record[++i]));
else if (Kind == Attribute::AllocKind)
B.addAllocKindAttr(static_cast<AllocFnKind>(Record[++i]));
- else if (Kind == Attribute::Memory)
- B.addMemoryAttr(MemoryEffects::createFromIntValue(Record[++i]));
- else if (Kind == Attribute::Captures)
+ else if (Kind == Attribute::Memory) {
+ uint64_t EncodedME = Record[++i];
+ const uint8_t Version = (EncodedME >> 56);
+ auto ME = MemoryEffects::createFromIntValue(EncodedME &
+ 0x00FFFFFFFFFFFFFFULL);
+ if (Version < 1) {
+ // Errno memory location was previously encompassed into default
+ // memory. Ensure this is taken into account while reconstructing
+ // the memory attribute prior to its introduction.
+ ModRefInfo OldOtherMR = ME.getModRef(IRMemLocation::ErrnoMem);
+ ME = MemoryEffects::inaccessibleMemOnly(
+ ME.getModRef(IRMemLocation::InaccessibleMem)) |
+ MemoryEffects::argMemOnly(
+ ME.getModRef(IRMemLocation::ArgMem)) |
+ MemoryEffects::errnoMemOnly(OldOtherMR) |
+ MemoryEffects::defaultMemOnly(OldOtherMR);
----------------
nikic wrote:
What I had in mind here was more along the lines of:
```
ModRefInfo ArgMem = ModRefInfo((EncodedME >> 0) & 3);
ModRefInfo InaccessibleMem = ModRefInfo((EncodedME >> 2) & 3);
ModRefInfo OtherMem = ModRefInfo((EncodedME >> 4) & 3);
ME = MemoryEffects::inaccessibleMemOnly(InaccessibleMem) |
MemoryEffects::argMemOnly(ArgMem) |
MemoryEffects::errnoMemOnly(OtherMem) |
MemoryEffects::defaultMemOnly(OtherMem);
```
Basically to entirely avoid instantiating MemoryEffects with the old value.
https://github.com/llvm/llvm-project/pull/120783
More information about the Mlir-commits
mailing list