[PATCH] D115218: [CodeExtractor] Refactor extractCodeRegion. NFCI.
Michael Kruse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 6 22:09:29 PST 2021
Meinersbur created this revision.
Meinersbur added reviewers: vzakhari, jroelofs, paquette, AndrewLitteken.
Herald added a subscriber: hiraditya.
Meinersbur requested review of this revision.
Herald added a project: LLVM.
Reorganize the code into phases:
1. Analyze/normalize
2. Create extracted function prototype
3. Generate the new function's implementation
4. Generate call to new function
5. Connect call to original function's CFG
The motivation is D115216 <https://reviews.llvm.org/D115216> to optionally clone the selected code region into the new function instead of moving it. The current structure made it difficult to add such functionality since there was no obvious place to do so, not made easier by some functions doing more than than their name suggests. For instance, `constructFunction` modifies code outside the constructed function, but also function properties such as `setPersonalityFn` are derived somewhere else. Another example is `emitCallAndSwitchStatement`, which despite its name also inserts stores for output parameters.
Many operations also implicitly depend on the order they are applied which this patch tries to reduce. For instance, `SwitchCases` becomes the list exit blocks which also defines the return value when leaving via that block. It is computed early such that the new function's return instructions and the switch can be generated independently. Also, `SwitchCases` is combining the lists `ExitBlocks` and `OldTargets` which were not always kept consistent with each other or `NumExitBlocks`. The method `recomputeExitBlocks()` will update it when necessary.
The coding style partially contradict the current coding standard. For instance some local variable start with lower case letters. I updated some, but not all occurrences to make the diff match at least some lines as unchanged.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D115218
Files:
llvm/include/llvm/Transforms/Utils/CodeExtractor.h
llvm/lib/Transforms/Utils/CodeExtractor.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115218.392277.patch
Type: text/x-patch
Size: 60026 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211207/89e5157d/attachment.bin>
More information about the llvm-commits
mailing list