[llvm-dev] How to inline function from other file in IR

via llvm-dev llvm-dev at lists.llvm.org
Wed May 16 06:15:51 PDT 2018


It sounds like you want to compile with LTO (-flto) after removing the 'inline' from 'foo'.  That should enable the cross-compilation-unit inlining you want.
--paulr

From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Soham Sinha via llvm-dev
Sent: Tuesday, May 15, 2018 7:33 PM
To: via llvm-dev
Subject: [llvm-dev] How to inline function from other file in IR

Hello,

How can I inline a function mentioned in other file?

I have an inline function foo in C source file (a.c) which is not referenced in this file. I compile this file to a.ll (I notice that the compiled a.ll doesn't have foo's definition, probably because it was inlined but not called anywhere)
I have another C source file b.c with function bar; I compile this to b.ll
I link these two files with llvm-link
I have written a pass which inserts foo function calls to the bar function at some points. I want foo function calls to be inlined. However, I get  compilation error because foo is not found (a.ll doesn't have foo)
If I remove the inline attribute of foo in a.c, I get the correctly compilation, with calls to foo inserted in bar from b.c
How do I achieve this kind of inline-ing?

Regards,
Soham Sinha
PhD Student, Department of Computer Science
Boston University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180516/bf9e8ec0/attachment.html>


More information about the llvm-dev mailing list