[LLVMdev] Privatize global variables

John Criswell criswell at illinois.edu
Sat Apr 7 22:11:33 PDT 2012


On 4/7/12 7:28 PM, Dmitry N. Mikushin wrote:
> 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,

The -internalize pass changes globals to have internal linkage.  Does 
this not suffice for your needs?

-- John T.

>
> 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.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list