It seems like llvm -inline pass only inlines small functions. Is there a way to inline all functions, no matter how big they are?
            Asked
            
        
        
            Active
            
        
            Viewed 1,378 times
        
    3
            
            
        
        piXel_pRo
        
- 159
 - 2
 - 14
 
- 
                    1Inlining was created to inline small functions. Why do you want to inline big ones? – ForceBru Apr 23 '15 at 17:24
 - 
                    i need to do some experiments on programs, but i cannot work with function calls. – piXel_pRo Apr 23 '15 at 17:29
 - 
                    Can i force inline every function?? – piXel_pRo Apr 23 '15 at 17:33
 - 
                    to my mind, it's useless as some functions simply cannot be inlined (for example, `main` LOL). Moreover, clang's smart enough to inline every function possible when you request it. I think it does its best when you ask it to do it. – ForceBru Apr 23 '15 at 17:36
 - 
                    1You can use the `always_inline` attribute and then the run the `-always-inline` pass (as in [this question](http://stackoverflow.com/questions/25602813/force-a-function-to-be-inline-in-clang-llvm)). That requires you to annotate every function though... – Ismail Badawi Apr 27 '15 at 03:18
 
1 Answers
3
            You can use the -inline-threshold flag to change the "cost" up to which LLVM will inline a function. A higher value means more functions will be inlined.
opt -inline -inline-threshold=10000 ...
Obviously functions can not always be inlined, particularly when the call graph contains cycles (recursive calls).
        cib
        
- 2,124
 - 2
 - 21
 - 23
 
- 
                    Is there any other reason (except for recursion) due to which a function might not get inlined ?? – piXel_pRo Jan 01 '16 at 15:00
 - 
                    Indirect function calls are not being inlined. Any help regarding that? – piXel_pRo Jan 23 '16 at 14:16