address spaces in llvm

Hi everyone,

There are different address spaces in llvm. Some of them are generic, shared, global, etc.

What is the difference between each of them? And when do we need to use them?

Best,

Mohammad

They’re mainly used in OpenCL environment. Check OpenCL’s document for more detail

Cheers,

McClane

The first address space is the default. This is currently a bit overloaded and assumes that functions and the stack all share the same address space (I have some patches to fix this, but they’ve not been upstreamed because no one else currently needs this functionality).

The next address spaces up to 255 are intended to capture some language-specific behaviour. For example, 1 is used by some front ends to represent garbage-collected pointers with the same representation as pointers in AS 0.

Those from 256 and up are target specific. For example, 256 and 257 on x86 represent gs- and fs-relative addresses and so are commonly used for things like thread-local storage.

David