)]}'
{
  "commit": "e9b2e16dc98345bb1b91b1a6dacb3cec85f49e31",
  "tree": "40ff2a43efac29a276cb835af47b91d6d61608d3",
  "parents": [
    "a3fea0643da544b2e5d5c48f2ea942dad22d01f2"
  ],
  "author": {
    "name": "eddyz87",
    "email": "eddyz87@gmail.com",
    "time": "Mon Aug 19 19:49:11 2024 +0300"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Mon Aug 19 19:49:11 2024 +0300"
  },
  "message": "[BPF] introduce `__attribute__((bpf_fastcall))` (#101228)\n\nThis commit introduces attribute bpf_fastcall to declare BPF functions\r\nthat do not clobber some of the caller saved registers (R0-R5).\r\n\r\nThe idea is to generate the code complying with generic BPF ABI, but\r\nallow compatible Linux Kernel to remove unnecessary spills and fills of\r\nnon-scratched registers (given some compiler assistance).\r\n\r\nFor such functions do register allocation as-if caller saved registers\r\nare not clobbered, but later wrap the calls with spill and fill patterns\r\nthat are simple to recognize in kernel.\r\n\r\nFor example for the following C code:\r\n\r\n     #define __bpf_fastcall __attribute__((bpf_fastcall))\r\n\r\n     void bar(void) __bpf_fastcall;\r\n     void buz(long i, long j, long k);\r\n\r\n     void foo(long i, long j, long k) {\r\n       bar();\r\n       buz(i, j, k);\r\n     }\r\n\r\nFirst allocate registers as if:\r\n\r\n    foo:\r\n      call bar    # note: no spills for i,j,k (r1,r2,r3)\r\n      call buz\r\n      exit\r\n\r\nAnd later insert spills fills on the peephole phase:\r\n\r\n    foo:\r\n      *(u64 *)(r10 - 8) \u003d r1;  # Such call pattern is\r\n      *(u64 *)(r10 - 16) \u003d r2; # correct when used with\r\n      *(u64 *)(r10 - 24) \u003d r3; # old kernels.\r\n      call bar\r\n      r3 \u003d *(u64 *)(r10 - 24); # But also allows new\r\n      r2 \u003d *(u64 *)(r10 - 16); # kernels to recognize the\r\n      r1 \u003d *(u64 *)(r10 - 8);  # pattern and remove spills/fills.\r\n      call buz\r\n      exit\r\n\r\nThe offsets for generated spills/fills are picked as minimal stack\r\noffsets for the function. Allocated stack slots are not used for any\r\nother purposes, in order to simplify in-kernel analysis.\r\n\r\nCorresponding functionality had been merged in Linux Kernel as\r\n[this](https://lore.kernel.org/bpf/172179364482.1919.9590705031832457529.git-patchwork-notify@kernel.org/)\r\npatch set (the patch assumed that `no_caller_saved_regsiters` attribute\r\nwould be used by LLVM, naming does not matter for the Kernel).",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "10a9d9e899e007fc9dde70facaac0f48ce8ba6b0",
      "old_mode": 33188,
      "old_path": "clang/include/clang/Basic/Attr.td",
      "new_id": "98bedfe20f5d980b192c4fda82d9d052a050a64c",
      "new_mode": 33188,
      "new_path": "clang/include/clang/Basic/Attr.td"
    },
    {
      "type": "modify",
      "old_id": "19cbb9a0111a28adef22fc711105ffa387f9a01b",
      "old_mode": 33188,
      "old_path": "clang/include/clang/Basic/AttrDocs.td",
      "new_id": "df36a2163b9f0b34dc0502d5a21bd4f7ff097c6e",
      "new_mode": 33188,
      "new_path": "clang/include/clang/Basic/AttrDocs.td"
    },
    {
      "type": "modify",
      "old_id": "e4f221ae55eefa1efeb150ce5f27db06fd5fdb64",
      "old_mode": 33188,
      "old_path": "clang/lib/CodeGen/CGCall.cpp",
      "new_id": "09803712569755d03163519fce4e17b1f59f0736",
      "new_mode": 33188,
      "new_path": "clang/lib/CodeGen/CGCall.cpp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "fa740d8e44ff519d50d0b3e46dd1485a50589f81",
      "new_mode": 33188,
      "new_path": "clang/test/CodeGen/bpf-attr-bpf-fastcall-1.c"
    },
    {
      "type": "modify",
      "old_id": "1a71556213bb16d2f59cd63d77da9cbbf5228a07",
      "old_mode": 33188,
      "old_path": "clang/test/Misc/pragma-attribute-supported-attributes-list.test",
      "new_id": "a7e425e3d5f43130551e8611ef0c1db975b51ec2",
      "new_mode": 33188,
      "new_path": "clang/test/Misc/pragma-attribute-supported-attributes-list.test"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "178b1f50741e87709f74edddf135c8e6011ef943",
      "new_mode": 33188,
      "new_path": "clang/test/Sema/bpf-attr-bpf-fastcall.c"
    },
    {
      "type": "modify",
      "old_id": "ef4ef1930aa8fb48fd184b4d7f870f56f408c35e",
      "old_mode": 33188,
      "old_path": "llvm/lib/Target/BPF/BPFCallingConv.td",
      "new_id": "a557211437e95f98962ba30912b3562a5fb9e8af",
      "new_mode": 33188,
      "new_path": "llvm/lib/Target/BPF/BPFCallingConv.td"
    },
    {
      "type": "modify",
      "old_id": "071fe004806e3e5d012189306352b878a28407af",
      "old_mode": 33188,
      "old_path": "llvm/lib/Target/BPF/BPFISelLowering.cpp",
      "new_id": "ff23d3b055d0d5cfe1475365ef8326179748db46",
      "new_mode": 33188,
      "new_path": "llvm/lib/Target/BPF/BPFISelLowering.cpp"
    },
    {
      "type": "modify",
      "old_id": "2ee630e29790f34956d4461c4c4219ead037e6ce",
      "old_mode": 33188,
      "old_path": "llvm/lib/Target/BPF/BPFInstrInfo.td",
      "new_id": "4baeeb017699d6958444c17f52a90479ed6bb6f7",
      "new_mode": 33188,
      "new_path": "llvm/lib/Target/BPF/BPFInstrInfo.td"
    },
    {
      "type": "modify",
      "old_id": "f0edf706bd8fd7a6026ddb785889dc2f1fa5ff5f",
      "old_mode": 33188,
      "old_path": "llvm/lib/Target/BPF/BPFMIPeephole.cpp",
      "new_id": "58dad71b920552671020f9220e62ad27101a0d0f",
      "new_mode": 33188,
      "new_path": "llvm/lib/Target/BPF/BPFMIPeephole.cpp"
    },
    {
      "type": "modify",
      "old_id": "84af6806abb36c08b9a52ee66e7d5375a1b9672b",
      "old_mode": 33188,
      "old_path": "llvm/lib/Target/BPF/BPFRegisterInfo.cpp",
      "new_id": "69e1318954a973a8cecd108091288eca8dbb1ec3",
      "new_mode": 33188,
      "new_path": "llvm/lib/Target/BPF/BPFRegisterInfo.cpp"
    },
    {
      "type": "modify",
      "old_id": "f7dea75ebea6f9e314a0d18a0a6e8b863dae7878",
      "old_mode": 33188,
      "old_path": "llvm/lib/Target/BPF/BPFRegisterInfo.h",
      "new_id": "db868769a1579a566d5a425b9179a45236200a52",
      "new_mode": 33188,
      "new_path": "llvm/lib/Target/BPF/BPFRegisterInfo.h"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "fd81314a495ef87fa22920ecf1d907439dea0deb",
      "new_mode": 33188,
      "new_path": "llvm/test/CodeGen/BPF/bpf-fastcall-1.ll"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "e3e29cdddca8ea6892500569326aa68fa5fd7c5e",
      "new_mode": 33188,
      "new_path": "llvm/test/CodeGen/BPF/bpf-fastcall-2.ll"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "81ca4e1ac57bc7c14a3496436a0f6d70984f512f",
      "new_mode": 33188,
      "new_path": "llvm/test/CodeGen/BPF/bpf-fastcall-3.ll"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "857d2f000d1d5a3053893b044cb3589d4bc3ad21",
      "new_mode": 33188,
      "new_path": "llvm/test/CodeGen/BPF/bpf-fastcall-regmask-1.ll"
    }
  ]
}
