[Mlir-commits] [llvm] [mlir] [IR][ModRef] Introduce `errno` memory location (PR #120783)

Antonio Frighetto llvmlistbot at llvm.org
Wed Feb 12 23:57:24 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);
----------------
antoniofrighetto wrote:

Right, indeed looks much better this way.

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


More information about the Mlir-commits mailing list