函数内联(FunctionInlining)是使用函数体代替函数调用的一种编译优化技术。LLVM中原生的内联模型只根据函数体的大小来判断函数内联与否,而没有考虑函数的调用次数和后续的优化。针对这个问题,提出了基于函数调用次数(NFC)和考虑后续循环合并(BLF)的新内联模型。首先,通过NFC模型对被多次调用的函数进行内联,进而减少更多因函数调用而产生的额外消耗。其次,通过BLF模型能够识别出进行内联后可以进一步进行循环合并优化的函数,为后续循环合并优化提供支持。实验结果表明,提出的函数内联优化技术是可行的,测试程序平均加速比为1.52%。
Function inlining is a compile optimization technique,that is using the body of a function instead of the callsite.LLVM’s original inline model considers the factor of the size of the function,but not considers the factor of executionfrequency and potential optimization opportunities.In this paper,a new inline model,considers both execution frequencyand potential optimization opportunities,proposed to avoid drawbacks of original inline model.The NFC model,can reduce consumption generated by calling more function calls,by inlining functions repeatedly called.The BLF modelprovides supports for the subsequent optimization for loop fusion,by inlining functions.In the experiment,function inliningoptimization model proposed by this paper is effective.Average speedup ratio of test program is1.52%.