[LLVMdev] Privatize global variables

Dmitry N. Mikushin maemarcus at gmail.com
Sat Apr 7 17:28:56 PDT 2012


Dear LLVM,

To workaround the GPU modules visibility rules, we need to lower
global variables into scope-variables of main entry and arguments in
other functions. For example,

int foo = 0;

int func() { return foo + 1; }

int main() { return func(); }

should become:

int func(int* foo) { return *foo + 1; }

int main() { int foo = 0; return func(&foo); }

Is there a strong name/term for this in compiler theory?
Do you know are there any related techniques already implemented in LLVM passes?
I'd much appreciate all points that could help us to better understand
the context.

Thanks,
- Dima.



More information about the llvm-dev mailing list