[all-commits] [llvm/llvm-project] 5cc034: [clang-repl] Enable native CPU detection by defaul...
Stefan Gränitz via All-commits
all-commits at lists.llvm.org
Wed Jan 10 02:49:15 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 5cc03442d392693d0d2457f571cc8fa1736bfe5e
https://github.com/llvm/llvm-project/commit/5cc03442d392693d0d2457f571cc8fa1736bfe5e
Author: Stefan Gränitz <stefan.graenitz at gmail.com>
Date: 2024-01-10 (Wed, 10 Jan 2024)
Changed paths:
M clang/lib/Interpreter/Interpreter.cpp
Log Message:
-----------
[clang-repl] Enable native CPU detection by default (#77491)
We can pass `-mcpu=native` to the clang driver to let it consider the
host CPU when choosing the compile target for `clang-repl`. We can
already achieve this behavior with `clang-repl -Xcc -mcpu=native`, but
it seems like a reasonable default actually.
The trade-off between optimizing for a specific CPU and maximum
compatibility often leans towards the latter for static binaries,
because distributing many versions is cumbersome. However, when
compiling at runtime, we know the exact target CPU and we can use that
to optimize the generated code.
This patch makes a difference especially for "scattered" architectures
like ARM. When cross-compiling for a Raspberry Pi for example, we may
use a stock toolchain like arm-linux-gnueabihf-gcc. The resulting binary
will be compatible with all hardware versions. This is handy, but they
will all have `arm-linux-gnueabihf` as their host triple. Previously,
this caused the clang driver to select triple `armv6kz-linux-gnueabihf`
and CPU `arm1176jzf-s` as the REPL target. After this patch the default
triple and CPU on Raspberry Pi 4b will be `armv8a-linux-gnueabihf` and
`cortex-a72` respectively.
With this patch clang-repl matches the host detection in Orc.
More information about the All-commits
mailing list