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.
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
Hi John,> The -internalize pass changes globals to have internal linkage. Does this > not suffice for your needs?To my understanding, it does not. The -internalize pass performs: I->setLinkage(GlobalValue::InternalLinkage); which means it only changes the linkage mode, while global variables remain in place. And we need to *replace* globals with local variables in main and arguments - in other functions. - D. 2012/4/8 John Criswell <criswell at illinois.edu>:> 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 > >
Apparently Analagous Threads
- [LLVMdev] Privatize global variables
- [LLVMdev] Privatize global variables
- Fwd: I cannot change value of global variable in LLVM IR using IRBuilder
- Fwd: I cannot change value of global variable in LLVM IR using IRBuilder
- Debug info error on bitcode inline modification