Repository navigation
Fix JIT miscompile of 0 / x after the update to LLVM 23 - #132041
Conversation
LLVM 23 `SimplifyDemandedUseFPClass` folded `+0.0 / x` to `copysign(0.0, x)` when `x` is known to be not NaN, ignoring that `0 / 0` is NaN. JIT-compiled expressions like `c0 * (0 / c0)` over an integer column returned `0` instead of `nan` for `c0 = 0` since the update to LLVM 23. Cherry-pick the upstream fix llvm/llvm-project#202482 into the fork: ClickHouse/llvm-project#156 Found by SQLancer (`Parallelism` oracle) on master: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=fdc4389b67de6aa94e602b884e1c403306184af7&name_0=NightlySQLancer&name_1=SQLancer%20%28arm_release%29 Caused by: #117346 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [2481497] Summary: ✅
AI ReviewSummaryThe LLVM update fixes incorrect results for JIT-compiled Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes453 object files changed (+71.04 KiB total), 0 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units11301 translation units recompiled, 40024 s compile time in total, 11301 of them have a recent master baseline. Symbol sizes
|
The previous bump pulled in the `thread_local` destructor secret change in `libcxxabi`, which calls `getentropy` without including `<sys/random.h>` on macOS. Move to the tip of `ClickHouse/release-23.x`, which adds that include (ClickHouse/llvm-project#157). CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=132041&sha=dbd91ed5a46a8ceaaaafc6c0c0075458f86e5cad&name_0=PR&name_1=Build%20%28arm_darwin%29 Related: #132041 Co-Authored-By: Claude Opus 5.5 <[email protected]>
LLVM 23
SimplifyDemandedUseFPClassfolds+0.0 / xtocopysign(0.0, x)whenxis known to be not NaN, ignoring that0 / 0is NaN. Since the update to LLVM 23, JIT-compiled expressions over integer columns (sitofpis never NaN, but can be zero) return wrong results:The upstream fix llvm/llvm-project#202482 is not in upstream
release/23.x; it is cherry-picked into the fork in ClickHouse/llvm-project#156, and this PR points the submodule at that commit (on top of the current fork tip, so it also includes theExtendedLLTrace fix from #131685 and the CFI fixes of ClickHouse/llvm-project#155). The pointer should be moved to the merge commit once the fork PR is merged.Verified locally on aarch64: an LLVM 23 O3 pipeline (as in
CHJIT) turnsfdiv 0.0, sitofp(x)intocopysign, and does not with the patch; the new test fails on a master build and passes with the patched LLVM linked in.Found by SQLancer (
Parallelismoracle; the third run of the same expression reachesmin_count_to_compile_expression) on master: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=fdc4389b67de6aa94e602b884e1c403306184af7&name_0=NightlySQLancer&name_1=SQLancer%20%28arm_release%29Caused by: #117346
Related: #128538
Related: #131685
Changelog category (leave one):
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/132041]
Version info
26.11.1.2623-master(included in26.11and later)