This trivial function isn't inlined at -O2: void factorial(int a, int* b) { *b = a + 1; } int main() { int a = 4; int b; factorial(a,&b); return b; } The reason is this code in llvm-backend.cpp: if (optimize > 1) { if (flag_inline_trees > 1) // respect -fno-inline-functions PM->add(createFunctionInliningPass()); // Inline small functions At -O2, flag_inline_trees is equal to 1, so this is not run.
gcc runs pass_early_ipa_inline when flag_inline_trees && flag_early_inlining It runs pass_ipa_inline when flag_inline_trees So I think we should not pay any attention to the -O level and just do the same.
Fixed here: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080421/061359.html