llvm outlining question

Is there any support for outlining in llvm?

As we know outlining is the opposite of inlining and while refactoring, if we can outlining common code into functions, then function merge (supported by llvm) can be more efficient in reducing code size.

If llvm support outlining, how to use it? Any documentation for it?

Thanks,
Ming-Hwa

Does this do what you want http://llvm.org/docs/doxygen/html/classllvm_1_1CodeExtractor.html?

CodeExtractor sort of does this.

First, it’s a utility, not a pass - you’d still need to wrap it up with pass that actually causes it to outlines what you want it to outline.

Second, it’s a bit buggy. There are, as far as I know, two in-tree users of this utility: bugpoint, and partial inlining. Both of them are fairly specialized use-cases, and don’t actually exercise the full generality of outlining an arbitrary region. And since a lot of cases are in practice untested - they don’t quite work.
I’ve had some fixes for this internally, but never actually upstreamed them, and no longer have access to that codebase. So, you’ll probably run into the same issues if you try to do anything untrivial with it.

Michael

Thank you Michael and Tom for the quick reply.

According to your experience and comments, CodeExtractor is buggy only works for special cases but not general enough for most usages. Then do we have other outlining solution in llvm? Or I have to repeat what Michel done before?

Best regards,
Ming-Hwa

I’m not aware of anything else in LLVM that performs outlining.
Ayal (CCed) may be able to help you regarding CodeExtractor fixes.

Thanks,
Michael

Hi Ayal,

Do you have any CodeExtractor fixes I can use?

Thanks,
Ming-Hwa

I’ll see what fixes of Michael I can find, including http://reviews.llvm.org/D9647.

If you have concrete examples showing failures, it would be good to open PRs with testcases. That can help drive such fixes.