This is an archive of the discontinued LLVM Phabricator instance.

Changes in ‘CodeExtractor’ for call-site block
Needs RevisionPublic

Authored by ashutosh.nema on Jan 21 2015, 9:21 PM.

Details

Reviewers
chandlerc
Summary

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.

  1. Made ‘codeReplacer’ as member of ‘CodeExtractor’
  1. Added a new method ‘getCodeReplacerIfAvailable’ to ‘CodeExtractor’ class.

This method return ‘codeReplacer’ block.

  1. ‘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.

  1. ‘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.

  1. Updated callsites to ‘constructFunction’ & ‘emitCallAndSwitchStatement’.
  1. In ‘CodeExtractor’ constructor setting ‘CodeReplacer’ as nullptr.

Files Modified:
include/llvm/Transforms/Utils/CodeExtractor.h
lib/Transforms/Utils/CodeExtractor.cpp

Diff Detail

Repository
rL LLVM

Event Timeline

ashutosh.nema retitled this revision from to Changes in ‘CodeExtractor’ for call-site block.
ashutosh.nema updated this object.
ashutosh.nema edited the test plan for this revision. (Show Details)
ashutosh.nema set the repository for this revision to rL LLVM.
ashutosh.nema added a subscriber: Unknown Object (MLST).
chandlerc requested changes to this revision.Mar 29 2015, 2:29 PM
chandlerc edited edge metadata.

There are a bunch of coding convention problems here. Also, you don't provide a test case that this fixes. It's hard to evaluate what problem you're actually solving without the test case.

This revision now requires changes to proceed.Mar 29 2015, 2:29 PM

Thanks Chandler for looking into this.

There are a bunch of coding convention problems here.

I’ll fix these.

Also, you don't provide a test case that this fixes.
It's hard to evaluate what problem you're actually solving without the test case.

I was trying to use code extractor for inner loops.
i.e.
for (i…N){

for(j..N)
{}

}

And like to move inner loop to a function.

CodeExtractor is moving loop to a outlined function properly:

OutlinedFunction(args)
{

for(j..N)
{}

}
for (i…N){

call OutlinedFunction(args) // call-site appears in a block

}

But it’s not registering call-site block to outer loop(if available).

Because of un registered call site block in outer loop, loop verification fails with below error:
"Loop block has no in-loop successors!".

I’m not very sure we can write test case for this because currently no optimization
moves inner loop to a outlined function. I can try if you have any suggestions.

So in this change, I exposed call site block.
If required, optimizations can register call-site block to outer loop.

Hope this explains the problem I'm trying to solve.

Regards,
Ashutosh