codegen: LLVM 21 ThreadSafeContext and EHFrame compatibility (#61273)
## Summary
- Add `withContextDo` compatibility shim for `ThreadSafeContext` API
changes in LLVM 21 (which removes `getLock()`, `Lock`, and
`getContext()` in favor of callback-based `withContextDo`)
- Replace all manual lock/unlock patterns with scoped `withContextDo`
callbacks across `jitlayers.h`, `jitlayers.cpp`, `aotcompile.cpp`, and
`disasm.cpp`
- Add `JLEHFrameRegistrationPlugin` for LLVM 21+ (which removes
`jitlink::EHFrameRegistrar`), using JITLink allocation actions for EH
frame registration
- Debug asserts ensure `get_context()`/`get_module()` are only called
inside `withContextDo` scope
- Lock hierarchy respected: TSC locks released before
`addOutput()`/`R->replace()` which can trigger materialization
Supersedes #59946 and #60358, forward-porting those changes to current
master.
## Test plan
- [x] Builds and passes smoke test on LLVM 20
- [x] Builds and passes smoke test on LLVM 21 (tested with libLLVM
21.1.2 JLL)
- [ ] CI
This pull request was written with the assistance of generative AI
(Claude).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
There is quite a few whitespace changes so ignoring it is quite helpful
---------
Co-authored-by: yuyichao <yyc1992@gmail.com>
Co-authored-by: Sam Schweigel <sam.schweigel@juliahub.com>