This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Make it explicit that attributes use the MCSubtargetInfo from TargetMachine. NFC
ClosedPublic

Authored by craig.topper on Jan 18 2023, 9:44 AM.

Details

Summary

The MCSTI variable is initialized to TM.getMCSubtargetInfo(), but is
re-assigned in every call to runOnMachineFunction. mitAttributes is
called before any call to runOnMachineFunction, but it's not
immediately obvious.

This patch removes the MCSTI variable, and instead queries
TM.getMCSubtargetInfo() at the time emitAttributes is called.

Diff Detail

Event Timeline

craig.topper created this revision.Jan 18 2023, 9:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2023, 9:44 AM
craig.topper requested review of this revision.Jan 18 2023, 9:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2023, 9:44 AM

Remove the MCSTI variable which becomes dead after this.

craig.topper edited the summary of this revision. (Show Details)Jan 18 2023, 9:57 AM
reames accepted this revision.Jan 18 2023, 10:37 AM

LGTM w/comment addressed.

llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
220–223

I think this needs a comment. The fact that we specifically *don't* want some arbitrary functions copy of the sub-target info is surprising, and worth a word or two here.

This revision is now accepted and ready to land.Jan 18 2023, 10:37 AM

It's called from emitStartOfAsmFile, so yes, it's going to be called before any of the functions are emitted and this really should be NFC. https://reviews.llvm.org/D73339 is responsible for (what is now) MCSTI and was done for RVC[1] but we don't need that any more.

[1] And that fix was more of a hack, because we do need the module-level features in order to emit the right attributes

Worth nothing that EmitHwasanMemaccessSymbols is surely doing bogus things with STI...

craig.topper retitled this revision from [RISCV] Make it explicit that attributes use the MCSubtargetInfo from TargetMachine. to [RISCV] Make it explicit that attributes use the MCSubtargetInfo from TargetMachine. NFC.Jan 18 2023, 11:20 AM
craig.topper edited the summary of this revision. (Show Details)
This revision was landed with ongoing or failed builds.Jan 18 2023, 11:32 AM
This revision was automatically updated to reflect the committed changes.