Skip to content

Keep compiled entries pointing at the functions after sanitizing names - #1081

Open
oscardssmith wants to merge 1 commit into
JuliaGPU:mainfrom
oscardssmith:os/sanitize-name-collisions
Open

oscardssmith wants to merge 1 commit into
JuliaGPU:mainfrom
oscardssmith:os/sanitize-name-collisions

Conversation

@oscardssmith

@oscardssmith oscardssmith commented Nov 5, 2026 •

Copy link
Copy Markdown

irgen sanitizes the names of defined functions (julia_f+_0 becomes julia_f__0) after compile_method_instance has recorded them in compiled. The entries for those functions then named functions that no longer exist in the module, on every Julia version.

From Julia 1.14, which numbers functions per compilation, sanitized names also collide: julia_+_0 and julia_-_0 both become julia___0. LLVM uniquifies the second one as julia___0.1, which is not a safe name. Consumers that sanitize compiled names themselves, like Enzyme's prepare_llvm, then look up julia___0_1 and miss the function. On main, both entries resolve to the same function instead.

This PR picks a free _N suffix when a sanitized name is taken, and updates compiled with the names actually given. The new test compiles two callees whose names collide after sanitizing. It checks that every name in compiled exists in the module, is safe and distinct, and refers to the right function. It fails on main on 1.13 and 1.14.

@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.48%. Comparing base (45e224f) to head (4e4bcdc).

Files with missing lines Patch % Lines
src/irgen.jl 81.81% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1081       +/-   ##
===========================================
- Coverage   92.86%   76.48%   -16.39%     
===========================================
  Files          31       31               
  Lines        7775     7564      -211     
===========================================
- Hits         7220     5785     -1435     
- Misses        555     1779     +1224     

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

`irgen` sanitizes the names of defined functions after `compiled` has
recorded them, so entries for functions like `julia_f+_0` named functions
that no longer exist. Record the names actually given and update the
entries.

Sanitized names can also collide, e.g. `julia_+_0` and `julia_-_0` from
Julia 1.14, which numbers functions per compilation. LLVM would then
uniquify the second name with a `.` suffix, which is not a safe name, so
pick a free `_N` suffix instead. That keeps consumers that sanitize
`compiled` names themselves, like Enzyme, finding the right function.

Co-authored-by: Tim Besard <tim.besard@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@maleadt
maleadt force-pushed the os/sanitize-name-collisions branch from 8162938 to 4e4bcdc Compare November 6, 2026 13:08
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