Skip to content

Keep unrelocated constgv globals as declarations.#872

Merged
maleadt merged 1 commit into
mainfrom
tb/constgv-declarations
Jul 10, 2026
Merged

Keep unrelocated constgv globals as declarations.#872
maleadt merged 1 commit into
mainfrom
tb/constgv-declarations

Conversation

@maleadt

@maleadt maleadt commented Jul 10, 2026

Copy link
Copy Markdown
Member

Julia object references (julia.constgv globals) are kept session-portable by stripping their initializers after codegen, with relocate_gvs! baking in the absolute addresses at the toplevel link step. Leaving them behind as internal globals with a null initializer made them fair game for optimization passes that run before relocation -- notably the GlobalOpt run in the PTX back-end's finish_module! -- which folded loads of them to inline nulls and deleted the globals, constant-folding e.g. device-side comparisons against Symbol literals (JuliaGPU/CUDA.jl#3185). Demote them to external declarations instead, which no pass can fold, and have relocate_gvs! restore initializer and linkage.

Julia object references (julia.constgv globals) are kept session-portable by
stripping their initializers after codegen, with relocate_gvs! baking in the
absolute addresses at the toplevel link step. Leaving them behind as internal
globals with a null initializer made them fair game for optimization passes
that run before relocation -- notably the GlobalOpt run in the PTX back-end's
finish_module! -- which folded loads of them to inline nulls and deleted the
globals, constant-folding e.g. device-side comparisons against Symbol literals
(JuliaGPU/CUDA.jl#3185). Demote them to external declarations instead, which
no pass can fold, and have relocate_gvs! restore initializer and linkage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@maleadt maleadt merged commit 1a9099b into main Jul 10, 2026
36 of 37 checks passed
@maleadt maleadt deleted the tb/constgv-declarations branch July 10, 2026 17:46
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.39%. Comparing base (6e70209) to head (9b76098).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #872      +/-   ##
==========================================
- Coverage   81.40%   81.39%   -0.02%     
==========================================
  Files          25       25              
  Lines        4755     4761       +6     
==========================================
+ Hits         3871     3875       +4     
- Misses        884      886       +2     

☔ 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.

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.

1 participant