Chuck Zhao
2010-Jul-27 14:46 UTC
[LLVMdev] inline callsites whose function definitions are in different file?
LLVM (2.7 release version) provides 2 implementations for inlining function callsites: - InlineSimple.cpp (-inline): inline simple callsites according to its cost analysis - InlineAlways.cpp (-always-inline): inline all callsites that are marked with "always_inline" attribute. They are both subclasses of Inline.cpp that assumes the function's definition (body) is in the same Module (file) as its callsites (that will be inlined). I am now having a situation that the functions are defined in file1.c (Module1) but all callsites are spread in file2, file3, ...fileN. Would LLVM be able to inline such callsites at compile time? I think the right approach is to conduct inlining at link time (via the LTO), but still wonder if it is possible to do it at compile time without heavy hacking. Thank you Chuck
Devang Patel
2010-Jul-27 16:40 UTC
[LLVMdev] inline callsites whose function definitions are in different file?
On Tue, Jul 27, 2010 at 7:46 AM, Chuck Zhao <czhao at eecg.toronto.edu> wrote:> LLVM (2.7 release version) provides 2 implementations for inlining > function callsites: > > - InlineSimple.cpp (-inline): inline simple callsites > according to its cost analysis > - InlineAlways.cpp (-always-inline): inline all callsites that are > marked with "always_inline" attribute. > > They are both subclasses of Inline.cpp that assumes the function's > definition (body) is in the same Module (file) as its callsites (that > will be inlined). > > > I am now having a situation that the functions are defined in file1.c > (Module1) but all callsites are spread in file2, file3, ...fileN. Would > LLVM be able to inline such callsites at compile time? > > I think the right approach is to conduct inlining at link time (via the > LTO), but still wonder if it is possible to do it at compile time > without heavy hacking.At compiler time while compiling file2.c, how would compile know about function definition in file1.c ? - Devang
Chuck Zhao
2010-Jul-27 16:46 UTC
[LLVMdev] inline callsites whose function definitions are in different file?
On 7/27/2010 12:40 PM, Devang Patel wrote:> On Tue, Jul 27, 2010 at 7:46 AM, Chuck Zhao<czhao at eecg.toronto.edu> wrote: >> LLVM (2.7 release version) provides 2 implementations for inlining >> function callsites: >> >> - InlineSimple.cpp (-inline): inline simple callsites >> according to its cost analysis >> - InlineAlways.cpp (-always-inline): inline all callsites that are >> marked with "always_inline" attribute. >> >> They are both subclasses of Inline.cpp that assumes the function's >> definition (body) is in the same Module (file) as its callsites (that >> will be inlined). >> >> >> I am now having a situation that the functions are defined in file1.c >> (Module1) but all callsites are spread in file2, file3, ...fileN. Would >> LLVM be able to inline such callsites at compile time? >> >> I think the right approach is to conduct inlining at link time (via the >> LTO), but still wonder if it is possible to do it at compile time >> without heavy hacking. > At compiler time while compiling file2.c, how would compile know about > function definition in file1.c ? > - > DevangI don't, and the compiler doesn't neither, that is the problem, unless I do hacking at compile time. E.g.: - put all such function's definitions into file1.c - force to compile file1.c 1st. - when compiling file2.c: . read file1.bc . attach to file2's module - do inline analysis + inlining - detach the attached file1.bc functions - repeat for other files. ... But I don't think this is a good/elegant approach, thus asking the LLVM-Dev group. Thank you Chuck
Reasonably Related Threads
- [LLVMdev] inline callsites whose function definitions are in different file?
- [LLVMdev] inline callsites whose function definitions are in different file?
- [LLVMdev] inline callsites whose function definitions are in different file?
- Syncing file with reference to another one
- save and load in R