Skip to content

missing optimization opportunity: recursive inlining #11879

@llvmbot

Description

@llvmbot
Bugzilla Link 11507
Version trunk
OS Linux
Attachments Test case in C++, The same test case in llvm-ir after opt -O3
Reporter LLVM Bugzilla Contributor
CC @d0k,@efriedma-quic

Extended Description

I saw a lot of std::map usage in the llvm compiler which uses lots of operators, especially to check if the map is empty. But thinking this check is cheap is too naive as you will see in the test case:

_ZNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EE8_M_eraseEPSt13_Rb_tree_nodeIS2_E is called with null as the second parameter. _ZNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EE8_M_eraseEPSt13_Rb_tree_nodeIS2_E itself starts with a comparison of the second parameter against null. So inlining this function can fold a lot (the test case is designed to be a completely empty program).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilla

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions