The default inliner currently marks all recursive functions as “never” inline when calculating the cost (CallAnalyzer::analyzeCall() in lib/Analysis/IPA/InlineCost.cpp). Is there any reason for this? Did anyone try to implement recursion inlining in the past and failed? Or succeeded, but it was dropped later on? All I found was a thread from a few years ago:
I would expect some performance benefits in recursion inlining, obviously at the cost of code size increase. However, the heuristics could be tuned up so as to get a reasonable size/performance tradeoff.