Skip to content

LLVM21 bug workaround: getFixedValue() - #9374

Open
mcourteaux wants to merge 4 commits into
mainfrom
mcourteaux/llvm21-load-elim-workaround
Open

LLVM21 bug workaround: getFixedValue()#9374
mcourteaux wants to merge 4 commits into
mainfrom
mcourteaux/llvm21-load-elim-workaround

Conversation

@mcourteaux

Copy link
Copy Markdown
Contributor

Test to see if Claude's analysis on a recent issue I ran into is indeed the fix for more than just my particular use case, but so many other tests which are just skipped now, due to LLVM 21 bug: llvm/llvm-project@d1500d12be60 (PR #169764)

Fixes [no tracking issue it seems]

Checklist

  • Tests added or updated (not required for docs, CI config, or typo fixes)
  • Documentation updated (if public API changed)
  • Python bindings updated (if public API changed)
  • Benchmarks are included here if the change is intended to affect performance.
  • Commits include AI attribution where applicable (see Code of Conduct)

@mcourteaux mcourteaux changed the title Mcourteaux/llvm21 load elim workaround LLVM21 bug workaround: getFixedValue() Aug 21, 2026
@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.08%. Comparing base (54cd1d8) to head (a68de1f).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9374      +/-   ##
==========================================
+ Coverage   69.89%   70.08%   +0.18%     
==========================================
  Files         261      261              
  Lines       79362    79370       +8     
  Branches    19349    19350       +1     
==========================================
+ Hits        55474    55629     +155     
+ Misses      17926    17906      -20     
+ Partials     5962     5835     -127     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@abadams

abadams commented Aug 24, 2026

Copy link
Copy Markdown
Member

We are about to delete support for llvm 21 after the next release, but no objections to merging this - this is a good fix to go into the Halide 22 release, which is still supposed to support llvm 21.

@alexreinking
alexreinking force-pushed the mcourteaux/llvm21-load-elim-workaround branch from a01623a to 7c72fc2 Compare August 24, 2026 20:21
@mcourteaux

Copy link
Copy Markdown
Contributor Author

There is an indefinite hang in correctness_vector_reductions on arm64. Gotta investigate.

@alexreinking alexreinking left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalidating my previous accept pending investigation into the vector-reductions hang.

mcourteaux and others added 4 commits August 26, 2026 09:00
LLVM 21's LoopAccessAnalysis::getStrideFromAddRec() queries a
scalable-vector access type's fixed element count without guarding
against ScalableVectorType, hitting a fatal assertion
(TypeSize::getFixedValue on a scalable TypeSize) inside
LoopLoadEliminationPass, which the default O3 pipeline always runs
regardless of Halide's own loop-opt settings. Fixed upstream in
LLVM 22. Loop load elimination looks for opportunities to forward a
store to a later load across loop iterations, which Halide-generated
code essentially never benefits from, so skip it entirely on affected
SVE targets under the buggy LLVM versions via
PassInstrumentationCallbacks::registerShouldRunOptionalPassCallback
rather than crash (or, in a no-asserts LLVM build, silently compute a
bogus stride).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
These tests were skipped under LLVM 21 + SVE2 because they tripped a
TypeSize::getFixedValue() assertion in LoopAccessAnalysis, reached via
LLVM's LoopLoadEliminationPass. The previous commit skips that pass on
SVE targets under LLVM < 22, which should make the underlying crash
unreachable; drop the test-level skips so CI on real ARM hardware can
confirm.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The unnamed llvm::Any parameter of the LoopLoadEliminationPass-skipping
lambda was passed by value; clang-tidy flags this as an unnecessary
copy since it's not used at all except as an unused reference param.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The skip removed in the previous commit attributed this test's LLVM 21
failure entirely to the LoopLoadEliminationPass getFixedValue() assert,
but its original comment also noted a hang under LLVM 20 tied to the
same upstream fix. Investigation shows the hang is a separate,
Halide-side bug: the reduce-padding recursion in
CodeGen_ARM::codegen_across_vector_reduce can fail to converge for
some SVE2 vector-reduce shapes, independent of LoopLoadEliminationPass.
Restore the skip so this test doesn't hang CI; the other 11 test skips
removed previously only ever hit the assert, not a hang, and stay
removed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mcourteaux
mcourteaux force-pushed the mcourteaux/llvm21-load-elim-workaround branch from 772305e to a68de1f Compare August 26, 2026 07:02
@mcourteaux

Copy link
Copy Markdown
Contributor Author

Conclusion: this hang was pre-existing, and the corresponding skip got incorrectly disabled by thinking it would have been fixed by this PR. Claude prepared a separate fix for this, but for the sake of reviewing and merging smaller PRs, I have open PR here: #9396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants