LLVM IR for inline functions

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

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

C has weird inline semantics.

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

C has weird inline semantics.

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

Weird indeed. In C, an 'inline' function definition with external linkage
may be ignored (the compiler may choose to treat it as an external call).
Making func1() 'static inline' emits IR for func1() with the 'inlinehint'
attribute; the front-end does not inline it for you. This is true for
either C or C++.
--paulr