This change is to expose call site block of outlined function in ‘CodeExtractor’.
When code extractor works on blocks inside a loop it extracts properly.
But it didn’t register extracted function call site block to loop.
Because of it loop verification fails with error:
"Loop block has no in-loop successors!".
Call site block registration to loop is very much needed.
I like to expose call site block (‘codeReplacer’) by adding getter functions to ‘CodeExtractor’ class.
So who ever using code extractor they can access that call-site block and register if needed.
Made following changes in CodeExtractor.
- Made ‘codeReplacer’ as member of ‘CodeExtractor’
- Added a new method ‘getCodeReplacerIfAvailable’ to ‘CodeExtractor’ class.
This method return ‘codeReplacer’ block.
- ‘constructFunction’ method works on ‘codeReplacer’ block and accepts as argument.
Now ‘codeReplacer’ block is a member to class so no need of passing it as argument.
- ‘emitCallAndSwitchStatement’ method works on ‘codeReplacer’ block and accepts as argument.
Now ‘codeReplacer’ block is a member to class so no need of passing it as argument.
- Updated callsites to ‘constructFunction’ & ‘emitCallAndSwitchStatement’.
- In ‘CodeExtractor’ constructor setting ‘CodeReplacer’ as nullptr.
Files Modified:
include/llvm/Transforms/Utils/CodeExtractor.h
lib/Transforms/Utils/CodeExtractor.cpp