[PATCH] D40413: [CodeExtractor] Add debug locations for new call and branch instrs.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 10:10:06 PST 2017


fhahn added a comment.

In https://reviews.llvm.org/D40413#942301, @aprantl wrote:

> This is probably okay. Is there an introduction into partial inlining somewhere? I'd like to better understand what the transformation is doing, so I can give more helpful review feedback.


Muth, Robert, and Saumra Debray. "Partial inlining." might be useful (although all PDF versions I found are not really good quality :(). The basic idea is to 1) create a clone of the original function `f_cloned`, 2) extract cold code from the cloned function into function `f_extracted` and 3) replace the cold code in `f_cloned` with a call to `f_extracted`. The smaller function `f_cloned` might be viable to inline where `f` was not. This is for example useful, if you have a function too big to inline directly, but with an early return at the beginning.

This patch adds debug info for the call instruction added in step 3) and the branch instruction from the artificial entry block added to `f_extracted` to ensure the function entry block does not have any predecessors.



================
Comment at: lib/Transforms/Utils/CodeExtractor.cpp:1040
+    // Try to find debug location in the first block of the outlined function
+    // and use that for the branch instruction jumping to it.
+    for (auto &I : *header)
----------------
aprantl wrote:
> Could you please copy the entire text of the description you added to this phabricator review into the comment here? It is non-obvious what we are doing here, and I prefer having the complete story in the comment.
I've adjusted the text for the position.


https://reviews.llvm.org/D40413





More information about the llvm-commits mailing list