Hayden Livingston
2015-Jul-01 00:43 UTC
[LLVMdev] Are global variables candiates for register allocation?
I was wondering if global variables can be candidates for register allocation. My use case is a global variable that is used in every function in my program. I'm wondering if it's better to pass it in, or let it stay as a global. Passing it in will require a bit of work.
Reid Kleckner
2015-Jul-01 01:53 UTC
[LLVMdev] Are global variables candiates for register allocation?
This came up in the past for GHC, and we recommended passing it as a parameter everywhere, as it lets the register allocator spill it under high register pressure. GCC has support for allocating globals in GPRs and removing that GPR from the allocatable set, but LLVM doesn't implement it so far as I know. On Tue, Jun 30, 2015 at 5:43 PM, Hayden Livingston <halivingston at gmail.com> wrote:> I was wondering if global variables can be candidates for register > allocation. My use case is a global variable that is used in every > function in my program. > > I'm wondering if it's better to pass it in, or let it stay as a global. > > Passing it in will require a bit of work. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150630/a2b56b70/attachment.html>
Hayden Livingston
2015-Jul-01 04:57 UTC
[LLVMdev] Are global variables candiates for register allocation?
Thanks, Reid. I'm not an optimization expert, but as a workaround, can I do the following: void myFunction() { int local = global; .. use local ... } ? On Tue, Jun 30, 2015 at 6:53 PM, Reid Kleckner <rnk at google.com> wrote:> This came up in the past for GHC, and we recommended passing it as a > parameter everywhere, as it lets the register allocator spill it under high > register pressure. > > GCC has support for allocating globals in GPRs and removing that GPR from > the allocatable set, but LLVM doesn't implement it so far as I know. > > On Tue, Jun 30, 2015 at 5:43 PM, Hayden Livingston <halivingston at gmail.com> > wrote: >> >> I was wondering if global variables can be candidates for register >> allocation. My use case is a global variable that is used in every >> function in my program. >> >> I'm wondering if it's better to pass it in, or let it stay as a global. >> >> Passing it in will require a bit of work. >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >
Reasonably Related Threads
- [LLVMdev] Are global variables candiates for register allocation?
- [LLVMdev] Are global variables candiates for register allocation?
- [LLVMdev] Calling into non-linked function via a pointer
- [LLVMdev] stability of llvm ir across releases
- [LLVMdev] OrcJIT in LLVM C bindings