Reason to remove address spaces

Hi all,

Can you please help me to understand the reason to remove address spaces as shown in julia/llvm-remove-addrspaces.cpp at 5650c93f1aa45a17c10c9482e5d3e0042cf4cc6b · JuliaLang/julia · GitHub

Thank you,
Kavindu

Only the Julia-specific address space information (used to model the garbage collector) is removed, because certain LLVM back-ends don’t handle that information. It also makes the LLVM IR look ugly (if you pass raw=true to code_llvm the information is retained).

2 Likes

@maleadt Thank you, I was able to see the address space by passing raw=true as you mentioned.

So address spaces are removing using RemoveJuliaAddrspaces pass, because those information cannot be hadled by the LLVM back-end.

Can you please let me know at which phase address spaces are removed?

We don’t for the main CPU back-ends because those handle Julia’s address spaces (i.e. they ignore it). GPU back-ends do need to put the pass in their pipeline.

2 Likes

Since address spaces are used to identify GC-tracked pointers within the optimizations phases, after the optimization phases, is address space information used for some other reason?

Not the Julia addrspaces, but for GPU backends, non-zero addrspaces are used to identify the GPU memory region being accessed. For example, in the AMDGPU LLVM backend, 0 is used for Generic pointers, 1 is for Global pointers, 5 is used for Private (stack) pointers, etc.

1 Like

@jpsamaroo, thank you for your input.

Let me summarize this. Please correct me if I am wrong.

  • Julia uses address spaces for two purposes,
    1. Julia specific address spaces(AS) to identify GC-tracked pointers for optimization phases
    2. GPU backend-specific AS to identify GPU memory regions
  • Julia specific AS are removed after the optimization phases.
  • GPU backend-specific AS are not removed like that.

That sounds about right to me!

If you don’t mind me asking, why are you asking about these addrspaces? Are you doing any work on Julia’s optimizations passes?

1 Like

Nope, I am reading on LLVM’s non-integral address space. Julia is the only thing I found that is used the non-integral address spaces.

1 Like