This is an archive of the discontinued LLVM Phabricator instance.

[wip/help] Access TargetMachine without crashing
AbandonedPublic

Authored by JonChesterfield on Jul 15 2023, 10:24 AM.

Details

Summary

Trying to access the TargetMachine from a module pass.

I think I've rediscovered https://llvm.org/docs/NewPassManager.html#status-of-the-new-and-legacy-pass-managers.

This is a module pass run from the backend. It looks like I have to choose between access to TargetPassConfig and allowing the new pass manager.

That is, the pass can be run using the new pass manager as that was encouraged during review, but it looks like I'll have to delete that if I want target information.

Cargo culting is not working. What other state do I need to set?
Tagging various people. I miss the mailing list. Discord won't let me in.

So far I've worked out that the pass constructor can't call getAnalysis, and doInitialization can, but doInitialization is only called by one of the pass managers.

Diff Detail

Event Timeline

JonChesterfield requested review of this revision.Jul 15 2023, 10:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2023, 10:24 AM
JonChesterfield edited the summary of this revision. (Show Details)Jul 15 2023, 10:44 AM
  • doInitialization works for one pass manager and not the other
JonChesterfield edited the summary of this revision. (Show Details)Jul 15 2023, 10:57 AM
llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
1318

This is not running on the crashing invocation

JonChesterfield edited the summary of this revision. (Show Details)
  • more confusion
JonChesterfield edited the summary of this revision. (Show Details)Jul 15 2023, 11:32 AM
JonChesterfield abandoned this revision.Jul 15 2023, 3:14 PM

Pretty sure this is a known limitation of the new pass manager.

What were you trying to use the target machine for here?

What were you trying to use the target machine for here?

I wanted to query the amount of LDS available for the architecture with the plan of setting [min max] frame dimensions on allocations. Working around by leaving max unspecified when unknown, where it is unknown because I couldn't make this ^ patch work. I think it would be possible to only use target machine from the old pass manager but that's a mess. Very tempting to delete the new pass manager code and go down that path, but probably better not to,

What were you trying to use the target machine for here?

I wanted to query the amount of LDS available for the architecture with the plan of setting [min max] frame dimensions on allocations. Working around by leaving max unspecified when unknown, where it is unknown because I couldn't make this ^ patch work. I think it would be possible to only use target machine from the old pass manager but that's a mess. Very tempting to delete the new pass manager code and go down that path, but probably better not to,

You should be able to have the TargetMachine as a member of the pass struct, passed in to the pass constructor in the passbuilder callback