[llvm-dev] Can we get interprocedural register allocation work across module boundary?

54 views
Skip to first unread message

vivek pandya via llvm-dev

unread,
Jul 5, 2016, 12:29:00 PM7/5/16
to Tim Amini Golling, Hal Finkel, Quentin Colombet, Matthias Braun, llvm-dev
Hello Mentors,

I have a very naive idea to get IPRA woking at link time and thus extending its scope to intermodule. I seek some help if it seems to be a feasible idea.

So idea is to take advantage of LTO's capability to work with bit code files. LTO can optimize number of bitcode files and combine them into a big module. LTO then generates native code for the big module. 

So does it seem feasible to have clang generates bit code files for the source code and then combine then with LTO and LTOCodeGenerater will use current IPRA infrastructure, so IPRA will be improved as now it can propagate actual regmask for procedures define in other modules (not system/external library calls).  If this is possible then one problem I can sense is requirement of huge memory to hold a big module for large projects. 

If this idea seems feasible please help me to shape a concrete work plan on this.

Sincerely,
Vivek

Mehdi Amini via llvm-dev

unread,
Jul 5, 2016, 2:24:40 PM7/5/16
to vivek pandya, llvm-dev, Matthias Braun

> On Jul 5, 2016, at 9:28 AM, vivek pandya <vivekv...@gmail.com> wrote:
>
> Hello Mentors,
>
> I have a very naive idea to get IPRA woking at link time and thus extending its scope to intermodule. I seek some help if it seems to be a feasible idea.
>
> So idea is to take advantage of LTO's capability to work with bit code files. LTO can optimize number of bitcode files and combine them into a big module. LTO then generates native code for the big module.

Yes, that’s how LTO works.

>
> So does it seem feasible to have clang generates bit code files for the source code and then combine then with LTO and LTOCodeGenerater will use current IPRA infrastructure, so IPRA will be improved as now it can propagate actual regmask for procedures define in other modules (not system/external library calls). If this is possible then one problem I can sense is requirement of huge memory to hold a big module for large projects.

I don’t understand what you describe, or how it changes from LTO how it works right now.

IPRA, how we implemented it, is a simple “codegen option” that can be enabled during LTO.

I think at some point at the beginning of the project, you mentioned some paper about IPRA during link-time and we told you that it was not relevant for LLVM because of the way LTO works: IPRA can be enabled transparently during LTO.


Mehdi


>
> If this idea seems feasible please help me to shape a concrete work plan on this.
>
> Sincerely,
> Vivek

_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

vivek pandya via llvm-dev

unread,
Jul 5, 2016, 11:28:26 PM7/5/16
to Mehdi Amini, llvm-dev, Matthias Braun
On Tue, Jul 5, 2016 at 11:54 PM, Mehdi Amini <mehdi...@apple.com> wrote:

> On Jul 5, 2016, at 9:28 AM, vivek pandya <vivekv...@gmail.com> wrote:
>
> Hello Mentors,
>
> I have a very naive idea to get IPRA woking at link time and thus extending its scope to intermodule. I seek some help if it seems to be a feasible idea.
>
> So idea is to take advantage of LTO's capability to work with bit code files. LTO can optimize number of bitcode files and combine them into a big module. LTO then generates native code for the big module.

Yes, that’s how LTO works.

>
> So does it seem feasible to have clang generates bit code files for the source code and then combine then with LTO and LTOCodeGenerater will use current IPRA infrastructure, so IPRA will be improved as now it can propagate actual regmask for procedures define in other modules (not system/external library calls).  If this is possible then one problem I can sense is requirement of huge memory to hold a big module for large projects.

I don’t understand what you describe, or how it changes from LTO how it works right now.

IPRA, how we implemented it, is a simple “codegen option” that can be enabled during LTO.
Ok I got your point. So using IPRA during LTO is a way to get most benefit out of IPRA but h\this will incur some overheads due to LTO. I think it would be better to try this experiment with a small application to provide a good example of this.
-Vivek  

vivek pandya via llvm-dev

unread,
Jul 7, 2016, 12:39:53 AM7/7/16
to Mehdi Amini, llvm-dev, Matthias Braun
On Wed, Jul 6, 2016 at 8:58 AM, vivek pandya <vivekv...@gmail.com> wrote:


On Tue, Jul 5, 2016 at 11:54 PM, Mehdi Amini <mehdi...@apple.com> wrote:

> On Jul 5, 2016, at 9:28 AM, vivek pandya <vivekv...@gmail.com> wrote:
>
> Hello Mentors,
>
> I have a very naive idea to get IPRA woking at link time and thus extending its scope to intermodule. I seek some help if it seems to be a feasible idea.
>
> So idea is to take advantage of LTO's capability to work with bit code files. LTO can optimize number of bitcode files and combine them into a big module. LTO then generates native code for the big module.

Yes, that’s how LTO works.

>
> So does it seem feasible to have clang generates bit code files for the source code and then combine then with LTO and LTOCodeGenerater will use current IPRA infrastructure, so IPRA will be improved as now it can propagate actual regmask for procedures define in other modules (not system/external library calls).  If this is possible then one problem I can sense is requirement of huge memory to hold a big module for large projects.

I don’t understand what you describe, or how it changes from LTO how it works right now.

IPRA, how we implemented it, is a simple “codegen option” that can be enabled during LTO.
Ok I got your point. So using IPRA during LTO is a way to get most benefit out of IPRA but h\this will incur some overheads due to LTO. I think it would be better to try this experiment with a small application to provide a good example of this.
-Vivek
I tried to use IPRA with -flto option like  -flto  -mllvm -enable-ipra -mllvm -debug-only=ip-regalloc but it seems that while lto is enabled code generator does not enable IPRA. because I don't get any debug information. Or Am I missing any options related to LTO here ?

Mehdi Amini via llvm-dev

unread,
Jul 7, 2016, 1:35:23 AM7/7/16
to vivek pandya, llvm-dev, Matthias Braun
On Jul 6, 2016, at 9:39 PM, vivek pandya <vivekv...@gmail.com> wrote:



On Wed, Jul 6, 2016 at 8:58 AM, vivek pandya <vivekv...@gmail.com> wrote:


On Tue, Jul 5, 2016 at 11:54 PM, Mehdi Amini <mehdi...@apple.com> wrote:

> On Jul 5, 2016, at 9:28 AM, vivek pandya <vivekv...@gmail.com> wrote:
>
> Hello Mentors,
>
> I have a very naive idea to get IPRA woking at link time and thus extending its scope to intermodule. I seek some help if it seems to be a feasible idea.
>
> So idea is to take advantage of LTO's capability to work with bit code files. LTO can optimize number of bitcode files and combine them into a big module. LTO then generates native code for the big module.

Yes, that’s how LTO works.

>
> So does it seem feasible to have clang generates bit code files for the source code and then combine then with LTO and LTOCodeGenerater will use current IPRA infrastructure, so IPRA will be improved as now it can propagate actual regmask for procedures define in other modules (not system/external library calls).  If this is possible then one problem I can sense is requirement of huge memory to hold a big module for large projects.

I don’t understand what you describe, or how it changes from LTO how it works right now.

IPRA, how we implemented it, is a simple “codegen option” that can be enabled during LTO.
Ok I got your point. So using IPRA during LTO is a way to get most benefit out of IPRA but h\this will incur some overheads due to LTO. I think it would be better to try this experiment with a small application to provide a good example of this.
-Vivek
I tried to use IPRA with -flto option like  -flto  -mllvm -enable-ipra -mllvm -debug-only=ip-regalloc but it seems that while lto is enabled code generator does not enable IPRA. because I don't get any debug information. Or Am I missing any options related to LTO here ?

You have to understand that there are two phases: compile to .o (bitcode when -flto is supplied) and linking.
The linking phase is actually when the code generator runs, so you need to pass the option to LLVM through the linker.
On OS X the linker will accept -mllvm options, but when you invoke the link phase through clang you have to use -Wl,  to pass the option to the linker.


— 
Mehdi
Reply all
Reply to author
Forward
0 new messages