)]}'
{
  "commit": "7d736b5b9adb055bf39341659985345680f67d09",
  "tree": "7386b6adedc6b7cfb700606fb33b73f4e021a562",
  "parents": [
    "6ab1ed8e94d1e4a2ba07abbcab4f80302631ab8b"
  ],
  "author": {
    "name": "Benoit Jacob",
    "email": "benoitjacob@google.com",
    "time": "Thu Jan 18 11:54:39 2024 -0500"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Thu Jan 18 16:54:39 2024 +0000"
  },
  "message": "Ukernels: simplify the architecture-specific bitcode build. (#16126)\n\nThis PR basically re-does how we build and link architecture-specific\r\nand generic bitcode, for CPU ukernels.\r\n\r\nThe main change is that we now build one separate ukernel bitcode file\r\nfor each CPU architecture, and it\u0027s the only thing that `iree-compile`\r\nneeds to load and link to. Before, it had to load and link together 3\r\ndifferent bitcode modules, two of which were actually compiled as\r\nWebAssembly for genericity, and it involved weak symbols. Full inlining\r\nis really important for performance here, and in this system, it\r\ndepended on two fragile mechanisms:\r\n1. Reinterpreting a WebAssembly module as a native module.\r\n2. Weak symbols.\r\n\r\nThat was done out of a concern for sharing generic code across\r\nsame-bitness architectures, but that turned out be substantially more\r\ncomplex in both the ukernels and the compiler, and to suffer from\r\nproblems described in #16000, which this PR fixes. Namely, the inlining\r\nacross these modules and down to the calling dispatch function was\r\nbrittle, never worked outside of x86, and to make even that work, we had\r\nto do some illegal target-attribute stripping that was effectively UB\r\nand caused issues described in\r\nhttps://github.com/llvm/llvm-project/issues/78206 (originally filed as a\r\nLLVM bug but then understood to be caused by our own illegal\r\nattribute-stripping).\r\n\r\nSo, we now build completely separate bitcode for each target CPU\r\narchitecture that we are supporting in `iree-compile`. At the moment,\r\nthat\u0027s roughly 20k of code for each additional architecture for which we\r\ndon\u0027t have dedicated optimized code paths. For comparison, each\r\narchitecture that does have dedicated code weighs roughly 100k. I found\r\nthat surprisingly large, until I remembered that IR is far more verbose\r\nthan object code. There are ways to control that if and when that\r\nbecomes a major concern:\r\n* We could further trim the supported CPU architectures, but note that\r\nwe gain simplicity from not doing so at the moment.\r\n* We could leave bitcode files separate rather than embedding them in\r\n`iree-compile`, allowing each user to obtain their own for their target\r\narchitecture.\r\n* We could just embed the ukernels *source* code, as pure C is so cheap\r\nto compile - the main cost would be now having to essentially build/ship\r\n`clang` as part of iree-compile, but supporting only C and not C++\r\nshouldn\u0027t be that bad.\r\n* One problem that that would also solve is that at the moment, for CPU\r\narchitectures for which `iree-compile` allows the user to pick from\r\nmultiple ABIs (looking at you, RISC-V --- you need to grow up, pick an\r\nABI and settle in life), compiling ukernels from source at that time\r\nwould make it trivial to have ukernels built for the right ABI. For now\r\nin this PR we just pick whichever ABI our tests are currently using.\r\n\r\nNote: this PR is broken into a few thematic commits to help reviewing.\r\n\r\nFixes #16000",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "2475b601309895044d35b32d29ebe1044ee16130",
      "old_mode": 33188,
      "old_path": "build_tools/bazel/iree_bitcode_library.bzl",
      "new_id": "27b1ed64ca06f2881391e02ccc892cdc8a98c8a6",
      "new_mode": 33188,
      "new_path": "build_tools/bazel/iree_bitcode_library.bzl"
    },
    {
      "type": "modify",
      "old_id": "7aae3cdce26fa5109c3758efc87f4090db3c5cbb",
      "old_mode": 33188,
      "old_path": "build_tools/cmake/iree_bitcode_library.cmake",
      "new_id": "0c685626ac3121ffaa6cf41ec9f3dd0b8b79b71c",
      "new_mode": 33188,
      "new_path": "build_tools/cmake/iree_bitcode_library.cmake"
    },
    {
      "type": "modify",
      "old_id": "84a4e7a10e5e97e277283d6abb364690b3649ed8",
      "old_mode": 33188,
      "old_path": "build_tools/cmake/iree_macros.cmake",
      "new_id": "bc9a303dd19f87da60fb07dbab44e3e1dab0d6dd",
      "new_mode": 33188,
      "new_path": "build_tools/cmake/iree_macros.cmake"
    },
    {
      "type": "modify",
      "old_id": "dd23c36c1ab27cfca9aa8aae174087ea8368c8cc",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Dialect/HAL/Target/LLVMCPU/Builtins/UKernel.cpp",
      "new_id": "46d1978d000b70a4eb41e4a87ba324d6c646d037",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Dialect/HAL/Target/LLVMCPU/Builtins/UKernel.cpp"
    },
    {
      "type": "modify",
      "old_id": "10e6f6bfa0e6d8f68f4cecc9005ca2890e4fbb28",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Dialect/HAL/Target/LLVMCPU/Builtins/UKernel.h",
      "new_id": "d788661dd8cd2c8287df1d8e02dfbbfa15e7e006",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Dialect/HAL/Target/LLVMCPU/Builtins/UKernel.h"
    },
    {
      "type": "modify",
      "old_id": "2ce3076de0b39f878824f93e9e3a7130dfe5d5f1",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Dialect/HAL/Target/LLVMCPU/LLVMCPUTarget.cpp",
      "new_id": "634e7ed421f3ef57de9663476fd368927b5551c4",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Dialect/HAL/Target/LLVMCPU/LLVMCPUTarget.cpp"
    },
    {
      "type": "modify",
      "old_id": "0cbdf64adef7564165584af8fabf9f562b24e3b5",
      "old_mode": 33188,
      "old_path": "runtime/src/iree/builtins/ukernel/BUILD.bazel",
      "new_id": "d71380383aaa0f98c495d8a5e620a533b91b6556",
      "new_mode": 33188,
      "new_path": "runtime/src/iree/builtins/ukernel/BUILD.bazel"
    },
    {
      "type": "modify",
      "old_id": "78c75119cca3b6a42e4bacc0c573ae8f49da3438",
      "old_mode": 33188,
      "old_path": "runtime/src/iree/builtins/ukernel/CMakeLists.txt",
      "new_id": "63b4bc70cf74c3b2e11fb7f6bee9edf4083b184c",
      "new_mode": 33188,
      "new_path": "runtime/src/iree/builtins/ukernel/CMakeLists.txt"
    },
    {
      "type": "modify",
      "old_id": "03e6756615959b9df6b8b6125cc951a95ec45b97",
      "old_mode": 33188,
      "old_path": "runtime/src/iree/builtins/ukernel/arch/BUILD.bazel",
      "new_id": "a222685a269d1b4dc57ad5addcb73bdd3cce2e49",
      "new_mode": 33188,
      "new_path": "runtime/src/iree/builtins/ukernel/arch/BUILD.bazel"
    },
    {
      "type": "modify",
      "old_id": "a9058382e388a8ff6d6853407b8cb902ea0dbecd",
      "old_mode": 33188,
      "old_path": "runtime/src/iree/builtins/ukernel/arch/CMakeLists.txt",
      "new_id": "273fd25e6774a3c080f8c729c27b36c335bd5ccb",
      "new_mode": 33188,
      "new_path": "runtime/src/iree/builtins/ukernel/arch/CMakeLists.txt"
    },
    {
      "type": "modify",
      "old_id": "3898b9f3ec2512f4558403a72bb62ec6d67795b2",
      "old_mode": 33188,
      "old_path": "runtime/src/iree/builtins/ukernel/arch/arm_64/BUILD.bazel",
      "new_id": "1103c01023365cb791a2f25094017a8dac1d2717",
      "new_mode": 33188,
      "new_path": "runtime/src/iree/builtins/ukernel/arch/arm_64/BUILD.bazel"
    },
    {
      "type": "modify",
      "old_id": "fd8f1b6040185c3ed8a949d8605c8d58c8899604",
      "old_mode": 33188,
      "old_path": "runtime/src/iree/builtins/ukernel/arch/arm_64/CMakeLists.txt",
      "new_id": "93019fec8c6cb51bb42a9a123dbccf32ead3bba6",
      "new_mode": 33188,
      "new_path": "runtime/src/iree/builtins/ukernel/arch/arm_64/CMakeLists.txt"
    },
    {
      "type": "rename",
      "old_id": "cdadc7d852d345fe4cc1f4cdedd810d347fa8d7f",
      "old_mode": 33188,
      "old_path": "runtime/src/iree/builtins/ukernel/arch/arm_64/mmt4d_arm_64.c",
      "new_id": "cdadc7d852d345fe4cc1f4cdedd810d347fa8d7f",
      "new_mode": 33188,
      "new_path": "runtime/src/iree/builtins/ukernel/arch/arm_64/mmt4d_arm_64_base.c",
      "score": 100
    },
    {
      "type": "rename",
      "old_id": "38e129d9899c34900094e378be569fd49f012a6c",
      "old_mode": 33188,
      "old_path": "runtime/src/iree/builtins/ukernel/arch/arm_64/pack_arm_64.c",
      "new_id": "38e129d9899c34900094e378be569fd49f012a6c",
      "new_mode": 33188,
      "new_path": "runtime/src/iree/builtins/ukernel/arch/arm_64/pack_arm_64_base.c",
      "score": 100
    },
    {
      "type": "rename",
      "old_id": "797e516d92f9eaa6f2a48b407130e1d534e40fdb",
      "old_mode": 33188,
      "old_path": "runtime/src/iree/builtins/ukernel/arch/arm_64/unpack_arm_64.c",
      "new_id": "797e516d92f9eaa6f2a48b407130e1d534e40fdb",
      "new_mode": 33188,
      "new_path": "runtime/src/iree/builtins/ukernel/arch/arm_64/unpack_arm_64_base.c",
      "score": 100
    },
    {
      "type": "modify",
      "old_id": "88a4cc8b153f2f0d6c3d1bc1238604923b3d0ff0",
      "old_mode": 33188,
      "old_path": "runtime/src/iree/builtins/ukernel/arch/x86_64/BUILD.bazel",
      "new_id": "ff6f7b1876ac4c879404ad644d878924f83f19a8",
      "new_mode": 33188,
      "new_path": "runtime/src/iree/builtins/ukernel/arch/x86_64/BUILD.bazel"
    },
    {
      "type": "modify",
      "old_id": "2d5b155baaeea62d0bf2847d832e13a46404ceb2",
      "old_mode": 33188,
      "old_path": "runtime/src/iree/builtins/ukernel/arch/x86_64/CMakeLists.txt",
      "new_id": "18c82743f557b10b244c6cf0a2f48b97cdc1b781",
      "new_mode": 33188,
      "new_path": "runtime/src/iree/builtins/ukernel/arch/x86_64/CMakeLists.txt"
    },
    {
      "type": "modify",
      "old_id": "21f03421d8a7bf08812591545f1ec938ac0bc5f3",
      "old_mode": 33188,
      "old_path": "runtime/src/iree/builtins/ukernel/common.h",
      "new_id": "afa25639a091eec9722c050a1b36885904caade6",
      "new_mode": 33188,
      "new_path": "runtime/src/iree/builtins/ukernel/common.h"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "eaee5b2e02e5731507b8c878e069924fc8797e10",
      "new_mode": 33188,
      "new_path": "runtime/src/iree/builtins/ukernel/fallback.c"
    },
    {
      "type": "delete",
      "old_id": "6ac984089c885ab3a9165af28cf9194139b845ae",
      "old_mode": 33188,
      "old_path": "runtime/src/iree/builtins/ukernel/weak.c",
      "new_id": "0000000000000000000000000000000000000000",
      "new_mode": 0,
      "new_path": "/dev/null"
    }
  ]
}
