Skip to content

Convert pointer address spaces when calling rtlib functions. #704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Jun 23, 2025

We currently emit runtime functions in the generic address space, while source arguments may reside in a specific address space, e.g., when pointing to global variables.

This only affects Julia 1.12, where Julia functions use actual pointers, and LLVM.jl 9.4.1+, which emits global strings in the correct address space.

Fixes JuliaLLVM/LLVM.jl#518 (cc @simeonschaub).

We currently emit runtime functions in the generic address space,
while source arguments may reside in a specific address space,
e.g., when pointing to global variables.

This only affects Julia 1.12, where Julia functions use actual pointers,
and LLVM.jl 9.4.1+, which emits global strings in the correct address space.
Copy link
Contributor

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic master) to apply these changes.

Click here to view the suggested changes.
diff --git a/src/rtlib.jl b/src/rtlib.jl
index 91b4c71..a9ba31a 100644
--- a/src/rtlib.jl
+++ b/src/rtlib.jl
@@ -54,8 +54,8 @@ function LLVM.call!(builder, rt::Runtime.RuntimeMethodInstance, args=LLVM.Value[
                 # pointers are passed as integers on Julia 1.11 and earlier
                 ptrtoint!(builder, args[i], parameters(ft)[i])
             elseif value_type(arg) isa LLVM.PointerType &&
-                   parameters(ft)[i] isa LLVM.PointerType &&
-                   addrspace(value_type(arg)) != addrspace(parameters(ft)[i])
+                    parameters(ft)[i] isa LLVM.PointerType &&
+                    addrspace(value_type(arg)) != addrspace(parameters(ft)[i])
                 # runtime functions are always in the default address space,
                 # while arguments may come from globals in other address spaces.
                 addrspacecast!(builder, args[i], parameters(ft)[i])

Copy link

codecov bot commented Jun 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.54%. Comparing base (772a78c) to head (6a2fe4a).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #704      +/-   ##
==========================================
+ Coverage   72.12%   73.54%   +1.42%     
==========================================
  Files          24       24              
  Lines        3483     3485       +2     
==========================================
+ Hits         2512     2563      +51     
+ Misses        971      922      -49     

☔ View full report in Codecov by Sentry.
📢 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.

@maleadt maleadt merged commit b8eecbf into master Jun 23, 2025
19 of 22 checks passed
@maleadt maleadt deleted the tb/runtime_addrspacecast branch June 23, 2025 12:03
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.

9.4.1 breaks GPUCompiler on Julia 1.12
1 participant