You might be interested in the CostModel
analysis pass. It's a pass which uses the codegen to estimate the cost associated with each instruction - you can run it on each instruction in your function and sum up the values for a rough estimate of the entire function.
From the inline documentation:
This file defines the cost model analysis. It provides a very basic cost estimation for LLVM-IR. This analysis uses the services of the codegen to approximate the cost of any IR instruction when lowered to machine instructions. The cost results are unit-less and the cost number represents the throughput of the machine assuming that all loads hit the cache, all branches are predicted, etc. The cost numbers can be added in order to compare two or more transformation alternatives.