)]}'
{
  "commit": "dfdda57a128cfb6ad391141c4a8e480cd8e4568a",
  "tree": "11316450cc8fe2dc47c1f4309837680bcd91fdc1",
  "parents": [
    "7280499e8ed6f0a67268fa0e97ca3a7a72e1cb0c"
  ],
  "author": {
    "name": "Alexander Popov",
    "email": "alexgpg@gmail.com",
    "time": "Mon Jul 04 09:27:05 2022"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Mon Jul 04 09:27:05 2022"
  },
  "message": "Fix DoNotOptimize() GCC compile error with some types (#1340) (#1424)\n\nNon-const DoNotOptimize() can\u0027t compile when used with some types.\r\nExample of code which can\u0027t compile:\r\n\r\nchar buffer3[3] \u003d \"\";\r\nbenchmark::DoNotOptimize(buffer3);\r\n\r\nError message:\r\n\r\nerror: impossible constraint in \u0027asm\u0027\r\n  asm volatile(\"\" : \"+r\"(value) : : \"memory\");\r\n\r\nIntroduced in 8545dfb (Fix DoNotOptimize() GCC copy overhead (#1340) (#1410))\r\n\r\nThe cause is compiler can\u0027t work with the +r constraint for types that can\u0027t\r\nbe placed perfectly in registers. For example, char array[3] can\u0027t be perfectly\r\nfit in register on x86_64 so it requires placed in memory but constraint\r\ndoesn\u0027t allow that.\r\n\r\nSolution\r\n- Use +m,r constraint for the small objects so the compiler can decide to use\r\n  register or/and memory\r\n- For the big objects +m constraint is used which allows avoiding extra copy\r\n  bug(see #1340)\r\n- The same approach is used for the const version of DoNotOptimize()\r\n  although the const version works fine with the \"r\" constraint only.\r\n  Using mixed r,m constraint looks more general solution.\r\n\r\nSee\r\n- Issue #1340 ([BUG] DoNotOptimize() adds overhead with extra copy of argument(gcc))\r\n- Pull request #1410 (Fix DoNotOptimize() GCC copy overhead (#1340) #1410)\r\n- Commit 8545dfb (Fix DoNotOptimize() GCC copy overhead (#1340) (#1410))",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "a4fc52df6fecd3e63ef1cccfd4a08890c1536971",
      "old_mode": 33188,
      "old_path": "include/benchmark/benchmark.h",
      "new_id": "58a8a30226df40ff02f349118006215d3fa8058a",
      "new_mode": 33188,
      "new_path": "include/benchmark/benchmark.h"
    },
    {
      "type": "modify",
      "old_id": "5c0d3b6eacae70632ac619f147f36de7c1fd83fe",
      "old_mode": 33188,
      "old_path": "test/donotoptimize_test.cc",
      "new_id": "96881666c991be26ce11382526e87ed33bc9c94b",
      "new_mode": 33188,
      "new_path": "test/donotoptimize_test.cc"
    }
  ]
}
