aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-08-28 16:46:09 +0200
committerGitHub <noreply@github.com>2025-08-28 16:46:09 +0200
commit82ada737b1cd05d69f15283415691e8411c0789a (patch)
treeed67b919ce856742d11696b06ca99bf87ad67152 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent3fb490cba476723e6fd4a5935f0b886ca4484eb1 (diff)
downloadllvm-82ada737b1cd05d69f15283415691e8411c0789a.zip
llvm-82ada737b1cd05d69f15283415691e8411c0789a.tar.gz
llvm-82ada737b1cd05d69f15283415691e8411c0789a.tar.bz2
[clang] Optimize EmbedExpr child iterator callback (#155803)
Instead of querying the bitwidth and signeness of the integer literal for every iteration, get the bitwidth directly from the `APIntStorage` and assume the signeness to be `true` since we set the type of the `EmbedExpr` to `Ctx.IntTy` and the type of the integer literal to that of the `EmbedExpr`, so it should always be signed, as long as `ASTContext::IntTy` is signed. Before: ``` $ hyperfine -r 50 -w 3 'bin/clang -c ../../benchmarks/embed.cpp -std=c++20 -fconstexpr-steps=1000000000' Benchmark 1: bin/clang -c ../../benchmarks/embed.cpp -std=c++20 -fconstexpr-steps=1000000000 Time (mean ± σ): 1.796 s ± 0.090 s [User: 0.961 s, System: 0.834 s] Range (min … max): 1.640 s … 2.150 s 50 runs ``` After: ``` $ hyperfine -r 50 -w 3 'bin/clang -c ../../benchmarks/embed.cpp -std=c++20 -fconstexpr-steps=1000000000' Benchmark 1: bin/clang -c ../../benchmarks/embed.cpp -std=c++20 -fconstexpr-steps=1000000000 Time (mean ± σ): 1.700 s ± 0.050 s [User: 0.909 s, System: 0.789 s] Range (min … max): 1.637 s … 1.880 s 50 runs ``` That is roughly .1s less, or whatever, 5% or something. The benchmark is simply: ```c++ constexpr char str[] = { #embed "sqlite3.c" suffix(,0) }; constexpr char str2[] = { #embed "sqlite3.c" suffix(,0) }; constexpr char str3[] = { #embed "sqlite3.c" suffix(,0) }; ``` where `sqlite3.c` contains the sqlite3 amalgamation (roughly 9 million characters).
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
0 files changed, 0 insertions, 0 deletions