Hello,
I decided to implement some of code compaction passes. To start, I chose basic block factoring out, suggested in article (Section 3.3). Unlike the article, I implemented procedural abstraction for basic blocks on LLVM-IR level (probably it was not the best choice) and faced a problem: Is there any efficient way to determine, what size will instruction take in some particular architecture?
Reference to the pass: https://github.com/skapix/codeCompaction
It is my first project, connected to LLVM infrastructure, I would appreciate any help.
llvm/Analysis/CodeMetrics.h is what the inliner/unroller/etc. use to estimate cost. It’s not particularly precise, but it’s good enough for most purposes.