This is an archive of the discontinued LLVM Phabricator instance.

[ORC] Require TargetProcessControl instance when constructing ExecutionSession.
ClosedPublic

Authored by lhames on Jun 22 2021, 2:11 AM.

Details

Summary

This will...

  1. Simplify ES+TPC-based utilities, which will now only need an ExecutionSession

instance.

  1. Simplify call and handle operations for wrapper functions, which will now be

able to be implemented on ExecutionSession.

  1. Simplify termination, since TargetProcessControl::disconnect can now be called automatically from ExecutionSession::endSession.

This patch updates all in-tree code and examples except for
LLJITWithRemoteDebugging, which I'm still looking in to.

Diff Detail

Event Timeline

lhames created this revision.Jun 22 2021, 2:11 AM
lhames requested review of this revision.Jun 22 2021, 2:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2021, 2:11 AM

Hi Lang

I think ES taking ownership of TPC makes a lot of sense. Sessions usually have a unique target process. I am not yet sure how it affects RPC scenarios, where clients might want to run multiple sessions subsequently or in parallel over one RPC connection. Separating the RPC parts from the TPC parts in OrcRPCTargetProcessControlBase? I didn't look into it, but it doesn't sound too bad on the first glance.

Simplify termination, since TargetProcessControl::disconnect can now be called automatically from ExecutionSession::endSession.

Does "can" mean it's a todo for a follow-up patch or was it supposed to be part of this review? ExecutionSession::endSession() hasn't changed (yet) and llvm-jitlink still calls TargetProcessControl::disconnect() manually.

This patch updates all in-tree code and examples except for LLJITWithRemoteDebugging

I will disable the example build+test for the moment and adjust+re-enable it once this patch landed.

+ a few minor details inline

llvm/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h
190

is -> in?

198

The null check moved here from the ExecutionSession constructor. Is there a reason why it can't go to the TargetProcessControl constructor right away?

llvm/lib/ExecutionEngine/Orc/TargetProcessControl.cpp
49

Another null check here. Add one more in OrcRPCTargetProcessControlBase?

llvm/tools/lli/lli.cpp
1075

Maybe auto &TPC = J->getExecutionSession().getTargetProcessControl() would aid readability here as well?

Hi Lang

Hi Stefan. Thank you for taking the time to take a look at this, and for the helpful feedback.

I think ES taking ownership of TPC makes a lot of sense. Sessions usually have a unique target process. I am not yet sure how it affects RPC scenarios, where clients might want to run multiple sessions subsequently or in parallel over one RPC connection. Separating the RPC parts from the TPC parts in OrcRPCTargetProcessControlBase? I didn't look into it, but it doesn't sound too bad on the first glance.

I think we can require a one-to-one correspondence between TargetProcessControl and ExecutionSession instances. TargetProcessControl authors can handle multiplexing multiple TargetProcessControl instances over one RPC connection if they care to.

Simplify termination, since TargetProcessControl::disconnect can now be called automatically from ExecutionSession::endSession.

Does "can" mean it's a todo for a follow-up patch or was it supposed to be part of this review? ExecutionSession::endSession() hasn't changed (yet) and llvm-jitlink still calls TargetProcessControl::disconnect() manually.

"can" is a todo for a follow-up patch.

This patch updates all in-tree code and examples except for LLJITWithRemoteDebugging

I will disable the example build+test for the moment and adjust+re-enable it once this patch landed.

That would be great if you could. I think you'll have an easier time updating it than I would.

llvm/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h
190

Good catch -- I'll fix this and update the patch.

198

You're right -- I think this would be better done in the TargetProcessControl constructor. I'll fix that when I update the patch.

llvm/lib/ExecutionEngine/Orc/TargetProcessControl.cpp
49

You're right -- Thanks!

llvm/tools/lli/lli.cpp
1075

Yes -- I think that would be an improvement. I'll update that.

sgraenitz accepted this revision.EditedJun 30 2021, 4:37 AM

LGTM!

I prepared a patch for the LLJITWithRemoteDebugging example: https://github.com/weliveindetail/llvm-project/commits/arcpatch-D104694 It's still unix-only and I need to double-check that it doesn't break Windows bots, but otherwise this should work. Build and test are currently disabled on main, so landing the change from this review should not break it.

This revision is now accepted and ready to land.Jun 30 2021, 4:37 AM