LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 2244 - LLVM inliner not run at -O2
Summary: LLVM inliner not run at -O2
Status: RESOLVED FIXED
Alias: None
Product: tools
Classification: Unclassified
Component: llvm-gcc (show other bugs)
Version: 2.2
Hardware: PC All
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords: code-quality
Depends on:
Blocks:
 
Reported: 2008-04-21 01:15 PDT by Chris Lattner
Modified: 2008-04-21 03:27 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lattner 2008-04-21 01:15:51 PDT
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.
Comment 1 Duncan Sands 2008-04-21 02:21:37 PDT
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.