Split llvm ir

Hello,

I have a situation to break/split function at llvm ir level of single function (if ir of single is more).

Can someone clarify, is it possible to get the size at llvm ir level of function and how to split it without affecting functionality of splitted function.

Thank you in advance.

Kind regards
Deep

You can probably use CodeExtractor for this purpose.

It does function outlining.

Regards,

Ashutosh

Hi,

Can someone clarify, is it possible to get the size at llvm ir level of function and how to split it without affecting functionality of splitted function.

What size are you talking about? The number of IR instruction?

Some time ago, I was working on something similar (maybe my information can be outdatedā€¦).

You can look at the CodeExtractor class and the method extractCodeRegion.

This can help you identifie the part of the function you can split.

You can get the Region by adding the following method to your class:

void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired();
}

and you get the region with RegionInfo* RI = &getAnalysis(*f).getRegionInfo();

Good luck,

Johan