This is an archive of the discontinued LLVM Phabricator instance.

Add TargetMachine::addEarlyAsPossiblePasses.
ClosedPublic

Authored by jlebar on Mar 30 2016, 11:52 AM.

Details

Summary

This is a hook to allow TargetMachine to install passes at the
EP_EarlyAsPossible PassManagerBuilder extension point.

Diff Detail

Repository
rL LLVM

Event Timeline

jlebar updated this revision to Diff 52097.Mar 30 2016, 11:52 AM
jlebar retitled this revision from to Add TargetMachine::addEarlyAsPossiblePasses..
jlebar updated this object.
jlebar added a reviewer: chandlerc.
jlebar added a subscriber: llvm-commits.
chandlerc requested changes to this revision.Apr 7 2016, 12:24 AM
chandlerc edited edge metadata.

I feel like it would be useful to implement this at least for one target (I'm assuming NVPTX) to show the use case before landing it...

This revision now requires changes to proceed.Apr 7 2016, 12:24 AM
jlebar added a comment.Apr 7 2016, 9:02 AM

I feel like it would be useful to implement this at least for one target (I'm assuming NVPTX) to show the use case before landing it...

Yes, see D18616.

(The problem, it seems to me, is that we ask people to aggressively split up patches but then don't have a good way to give reviewers the full context. I can manually go in to Phabricator and set the depends-on metadata, but when I'm posting a dozen small patches, the relative time cost of doing that is huge. It needs to Happen Automatically.)

Chandler, are you happy with this? It seemed like the main problem was that I hadn't linked to D18616 originally.

Chandler, friendly ping.

Friendly ping.

koriakin added inline comments.
include/llvm/Target/TargetMachine.h
223 ↗(On Diff #52097)

Where do you call this function?

jlebar added inline comments.Apr 27 2016, 10:44 AM
include/llvm/Target/TargetMachine.h
223 ↗(On Diff #52097)

It's called from clang, or whatever is setting up the pass manager. D18617.

rnk added a subscriber: rnk.Apr 27 2016, 10:55 AM

Shouldn't this patch also modify the pass pipeline to call this hook at some point?

include/llvm/Target/TargetMachine.h
220–221 ↗(On Diff #52097)

Maybe this should say "before all mid-level optimization passes". I initially assumed you wanted this to run before IR-level codegen passes (CodeGenPrepare, LSR, etc), but that's what we have today.

In D18614#414054, @rnk wrote:

Shouldn't this patch also modify the pass pipeline to call this hook at some point?

AFAICT, it needs to be done outside of llvm proper, see D18617.

include/llvm/Target/TargetMachine.h
220–221 ↗(On Diff #52097)

I actually do want to run before IR-level codegen passes, see D18617. I agree that the comment isn't clear, I will change it.

jlebar updated this revision to Diff 55264.Apr 27 2016, 11:00 AM
jlebar edited edge metadata.

Clarify comment.

jlebar marked an inline comment as done.Apr 27 2016, 11:00 AM
rnk accepted this revision.Apr 27 2016, 11:32 AM
rnk added a reviewer: rnk.

lgtm

include/llvm/Target/TargetMachine.h
223 ↗(On Diff #55264)

As discussed, we should call it from opt as well, then. opt should have a TargetMachine somewhere.

jlebar updated this revision to Diff 55277.Apr 27 2016, 11:51 AM
jlebar edited edge metadata.

Call addEarlyAsPossiblePasses from opt.

jlebar marked an inline comment as done.Apr 27 2016, 12:06 PM
This revision was automatically updated to reflect the committed changes.