Abstract
Code size optimization is an important issue due to limited resources in embedded systems such as smartphones, tablet personal computers, and plenty of electronic devices. With the rapid growth of computing capability in recent years, many web programs, system software, and user applications used on personal computers are redesigned for embedded systems. Since these devices are designed to be lighter and handier which are with more resource constrains such as built-in memory space, storage space, and energy. Code size reduction is important which helps to remove redundant code and save storage space. Procedural abstraction extracts duplicate code segments into a newly created function and hence reduces code size. This thesis is based on previous work which introduced an approach to do procedural abstraction on Low Level Virtual Machine intermediate representation (LLVM IR) and estimated the basic block cost by instruction counts in Basic Blocks. However, the estimated value will be changed by several steps in LLVM compilation flow and lead to different result when it comes into object files. The cost model plays an important role in making a decision for basic blocks extraction in groups. We introduce a new approach to estimate the basic block weight. We try to find relationship of input IR and output object file size by a matrix scheme, form the approximation solution with a new cost model, and substitute the old one. The implementation of our work with procedural abstraction is based on the cost model and profiling information to decide whether a basic block should be extracted or not. After compiling the code into native arm executable file, we found that the code size reduction ratio reaches 21\% over O0 in the best case. In some cases, we can find more groups which will be rejected by previous cost model. Experiment results show that our code density is better than O0 and O2 options by using procedural abstraction in most cases. Finally, we also propose future works for code size opportunities.