[LLVMdev] LLVM IR for inline functions

David Blaikie dblaikie at gmail.com
Sat Apr 18 18:45:27 PDT 2015


C has weird inline semantics.

Try compiling the same thing as C++ & you might get something more reasonable?

On Sat, Apr 18, 2015 at 6:36 PM, Zhoulai <zell08v at gmail.com> wrote:
> Hi,
>
> I have a naive question on how to generate LLVM IR for inline functions. I
> have compiled this C code:
>
> inline void func1()
> {
> int x=3;
> }
> void func2()
> {
> func1();
> int y = 4;
>
> }
>
> into LLVM IR, using
>
> clang -emit-llvm -S -c <filename>
>
> But the generated LLVM IR file does *not* have func1() expanded (see below
> for the relevant parts).
>
> ; Function Attrs: nounwind uwtable
> define void @func2() #0 {
> entry:
> %y = alloca i32, align 4
> call void (...)* @func1()
> store i32 4, i32* %y, align 4
> ret void
> }
>
> declare void @func1(...) #1
>
> Question: Do I need to pass some special command line options so to make
> func1() expanded in the LLVM IR? Thanks.
>
> Zhoulai
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



More information about the llvm-dev mailing list