Note: This commit includes copy-and-paste from LLVM and thus adds the LLVM copyright notice. cf. https://github.com/llvm/llvm-project/commit/0a1aa6cda2758b0926a95f87d39ffefb1cb90200 cf. https://github.com/llvm/llvm-project/commit/a1e9777b760fbd4428073fd7b0fc8bea15bd2183 cf. https://github.com/llvm/llvm-project/commit/56c72c7f339cd6ff780a0d6aa1a0ac8bfc1487aa