This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Derive GCNSubtarget from MF to get overridden target features
ClosedPublic

Authored by dstuttard on Nov 9 2018, 3:26 AM.

Details

Summary

AMDGPUAsmPrinter has a getSTI function that derives a GCNSubtarget from the
TM. However, this means that overridden target features are not detected and can
result in incorrect behaviour.

Switch to using STM which is a GCNSubtarget derived from the MF (used elsewhere
in the same function).

Change-Id: Ib6328ad667b7fcdc87e9c06344e59859207db9b0

Diff Detail

Repository
rL LLVM

Event Timeline

dstuttard created this revision.Nov 9 2018, 3:26 AM

Scott - you made some changes here most recently so adding you as the reviewer.

I don't quite understand what distinguishes the two versions of MCSubtargetInfo (getSTI() vs STM), but it appears a patch from Konstantin earlier this year changed this specific instance from STM.getFeatureBits() to getSTI(). Changing this back LGTM but I don't know what the rationale was in the first place, if it wasn't a typo, so I don't want to sign off without asking.

I don't quite understand what distinguishes the two versions of MCSubtargetInfo (getSTI() vs STM), but it appears a patch from Konstantin earlier this year changed this specific instance from STM.getFeatureBits() to getSTI(). Changing this back LGTM but I don't know what the rationale was in the first place, if it wasn't a typo, so I don't want to sign off without asking.

My assumption is that it was neater to use the getSTI() member function provided - but that get the GCNSubtarget from the TargetMachine rather than MachineFunction - in most cases I guess this doesn't matter - but in our case the MF has got subtarget features enabled that the TM version doesn't. I wonder if the getSTI should be changed to use the MF version and all references to STM moved over to use getSTI().

Like you I'm not 100% sure there isn't a reason to use the TargetMachine derived version - so I guess we need Konstantin to comment.

This revision is now accepted and ready to land.Nov 16 2018, 10:06 AM
This revision was automatically updated to reflect the committed changes.