)]}'
{
  "commit": "c62ed161bb7a1aaeeba4437f4885a909c49f3ad6",
  "tree": "31d448611ec10458a4a0ec4d550e2b4effdca89e",
  "parents": [
    "57086ca697ade16c6043d08112522bad1ba30e31"
  ],
  "author": {
    "name": "Han-Chung Wang",
    "email": "hanhan0912@gmail.com",
    "time": "Mon Jan 12 13:32:26 2026 -0800"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Mon Jan 12 13:32:26 2026 -0800"
  },
  "message": "[VM] Preserve mutability for globals and rely on fixup to update it. (#23031)\n\nThe pass already runs fixupGlobalMutability method after initializing\nall globals with initial values. If the mutability is not preserved, it\ntriggers a bug in [the fixup\nmethod](https://github.com/iree-org/iree/blob/f4b596d5b2a8813948f6dab18a36403e768eb5e1/compiler/src/iree/compiler/Dialect/VM/Transforms/GlobalInitialization.cpp#L98-L114).\n\nIf we always set mutable for the new globals, didChange is always true.\nBecause it at least has one store.\n\n```cpp\n  explorer.forEachGlobal([\u0026](const Explorer::GlobalInfo *globalInfo) {\n    if (globalInfo-\u003euses.empty())\n      return;\n    // TODO(benvanik): verify we want this behavior - we likely want to change\n    // this to be mutable only if stores exist outside of initializers.\n    //\n    // If there are stores mark the global as mutable. We need to update all\n    // of the loads if this changes anything.\n    bool hasStores \u003d !globalInfo-\u003egetStores().empty();\n    bool didChange \u003d globalInfo-\u003eop.isGlobalMutable() !\u003d hasStores;\n    if (didChange) {\n      globalInfo-\u003eop.setGlobalMutable(hasStores);\n      for (auto loadOp : globalInfo-\u003egetLoads()) {\n        loadOp.setGlobalImmutable(!hasStores);\n      }\n    }\n  });\n```\n\nFixes https://github.com/iree-org/iree/issues/22880\n\nSigned-off-by: hanhanW \u003chanhan0912@gmail.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "434de313170282caf2261bb4b515235b166c4dc0",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Dialect/VM/Transforms/GlobalInitialization.cpp",
      "new_id": "98b47b80ad9c4f7cc95ec2c7a2f041e788716e16",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Dialect/VM/Transforms/GlobalInitialization.cpp"
    },
    {
      "type": "modify",
      "old_id": "44f6e400f6b91873350cb16279c37eaa59f4702e",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Dialect/VM/Transforms/test/global_initialization.mlir",
      "new_id": "35e8ea0412c91573d8fd915d66ff90b16940b9b9",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Dialect/VM/Transforms/test/global_initialization.mlir"
    }
  ]
}
