)]}'
{
  "commit": "a6e1700fa622f75436c3c3ead23b1eefb67e88ea",
  "tree": "83cf16981b362fdcad1150945e75e170f7eb19a1",
  "parents": [
    "cad62df49a79df5e5136cfad280c5abc9f62c60b"
  ],
  "author": {
    "name": "Kunqiu Chen",
    "email": "camsyn@foxmail.com",
    "time": "Mon Jul 14 15:45:08 2025 +0800"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Mon Jul 14 15:45:08 2025 +0800"
  },
  "message": "[Utils][Local] Preserve !nosanitize in combineMetadata when merging instructions (#148376)\n\n`combineMetadata` helper currently drops `!nosanitize` metadata when\nmerging two instructions, even if both originally carried `!nosanitize`.\n\nThis is problematic because `!nosanitize` is a key mechanism used by\nsanitizer (e.g., ASan) to suppress instrumentation. Removing it can lead\nto unintended sanitizer behavior.\n\nThis patch adds `nosanitize` to the whitelist in combineMetadata,\npreserving it only if both instructions carry `!nosanitize`; otherwise,\nit is dropped. This patch also adds corresponding tests in a test file\nand regenerates it.\n\n---\n### Details\n\n**Example (see [Godbolt](https://godbolt.org/z/83P5eWczx) for\ndetails**):\n\n```llvm\n%v1 \u003d load i32, ptr %p, !nosanitize\n%v2 \u003d load i32, ptr %p, !nosanitize\n```\nWhen merged via `combineMetadata(%v1, %v2, ...)`, the resulting\ninstruction loses its `!nosanitize` metadata.\n\nTools such as UBSan and AFL rely on `nosanitize` to prevent unwanted\ntransformations or checks. However, the current implementation of\ncombineMetadata mistakenly drops !nosanitize. This may lead to\nunintended behavior during optimization.\n\nFor example, under `-fsanitize\u003daddress,undefined -O2`, IR emitted by\nUBSan may lose its `!nosanitize` metadata due to the incorrect metadata\nmerging in optimization. As a result, ASan could unexpectedly instrument\nthose instructions.\n\u003e Note: due to the current UBSan handlers having relatively\ncoarse-grained attributes, this specific case is difficult to reproduce\nend-to-end from source code—UBSan currently inhibits such optimizations\n(refer to #135135 for details).\n\nStill, I believe it\u0027s necessary to fix this now, to support future\nversions of UBSan that might allow such optimizations, and to support\nthird-party tools (such as AFL-based fuzzers) that rely on the presence\nof !nosanitize.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "f5208d50c6aaebd390a54ba6a627bbe5796bf813",
      "old_mode": 33188,
      "old_path": "llvm/lib/Transforms/Utils/Local.cpp",
      "new_id": "81d85375b9e1d3f240e16d331455cbaeb0c70a79",
      "new_mode": 33188,
      "new_path": "llvm/lib/Transforms/Utils/Local.cpp"
    },
    {
      "type": "modify",
      "old_id": "a5dbb5ee060701bd8a77eb756d61c4154bf2177a",
      "old_mode": 33188,
      "old_path": "llvm/test/Transforms/GVN/metadata.ll",
      "new_id": "ff055d889eac26bde7e5028c6c0a8b6bbb872ebc",
      "new_mode": 33188,
      "new_path": "llvm/test/Transforms/GVN/metadata.ll"
    }
  ]
}
