This is an archive of the discontinued LLVM Phabricator instance.

[MachineInst] Switch NumOperands to 16bits
ClosedPublic

Authored by xbolva00 on Apr 28 2023, 6:42 AM.

Details

Summary

Decrease NumOperands from 32 to 16bits (matches MCInstrDesc) so we can use saved bits to extend Flags (https://reviews.llvm.org/D118118).

Diff Detail

Event Timeline

xbolva00 created this revision.Apr 28 2023, 6:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2023, 6:42 AM
xbolva00 requested review of this revision.Apr 28 2023, 6:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2023, 6:42 AM
xbolva00 updated this revision to Diff 517900.Apr 28 2023, 6:44 AM
xbolva00 updated this revision to Diff 517902.Apr 28 2023, 6:48 AM
xbolva00 edited the summary of this revision. (Show Details)Apr 28 2023, 6:50 AM
xbolva00 added inline comments.
llvm/lib/CodeGen/MachineInstr.cpp
744

MCID:
unsigned short NumOperands;

so OK.

nikic resigned from this revision.Apr 28 2023, 6:56 AM

Change seems conceptually fine, but I don't really know anything about the machine layer and couldn't say whether this is safe or not.

xbolva00 updated this revision to Diff 517909.Apr 28 2023, 7:02 AM

Use USHRT_MAX. Added check.

craig.topper added inline comments.Apr 28 2023, 5:00 PM
llvm/include/llvm/CodeGen/MachineInstr.h
519

You can leave this returning unsigned

626

Leave this returning unsigned

llvm/lib/CodeGen/MachineFunction.cpp
937 ↗(On Diff #517909)

Leave this as unsigned.

xbolva00 updated this revision to Diff 518344.Apr 30 2023, 12:13 PM

Addressed review feedback.

xbolva00 marked 3 inline comments as done.Apr 30 2023, 12:13 PM

any futher comments?

barannikov88 accepted this revision.May 2 2023, 8:44 AM
barannikov88 added a subscriber: barannikov88.

Looks fine. Just in case, in D118118 you will need to change the order of fields in order to avoid padding between them.

This revision is now accepted and ready to land.May 2 2023, 8:44 AM
This revision was automatically updated to reflect the committed changes.

This change broke the build for an internal project of ours (breadcrumb: rdar://109362033). The relevant code being compiled is a fairly large nested switch that results in a PHI node with 65k+ operands, which can't easily be turned into a table for perf reasons.

WDYT about making it the lower 24 bits of a uint32_t bitfield shared with AsmPrinterFlags in the upper 8?

This change broke the build for an internal project of ours (breadcrumb: rdar://109362033). The relevant code being compiled is a fairly large nested switch that results in a PHI node with 65k+ operands, which can't easily be turned into a table for perf reasons.

WDYT about making it the lower 24 bits of a uint32_t bitfield shared with AsmPrinterFlags in the upper 8?

Sounds fine to me

This change broke the build for an internal project of ours (breadcrumb: rdar://109362033). The relevant code being compiled is a fairly large nested switch that results in a PHI node with 65k+ operands, which can't easily be turned into a table for perf reasons.

WDYT about making it the lower 24 bits of a uint32_t bitfield shared with AsmPrinterFlags in the upper 8?

Sounds fine to me

https://reviews.llvm.org/D153791