This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Stabilize sort in GET_SUBTARGETINFO_MACRO block
ClosedPublic

Authored by kpn on Jun 20 2023, 11:35 AM.

Details

Summary

The sort of the elements in the GET_SUBTARGETINFO_MACRO block is done on the "Name" field of each record. This field is not guaranteed to be unique, is not guaranteed to even have a value at all, and is not used in the output anyway. Change to sort on the "Attribute" field which should be unique.

Problem spotted when lib/Target/PowerPC/PPCGenSubtargetInfo.inc changed unexpectedly.

Diff Detail

Event Timeline

kpn created this revision.Jun 20 2023, 11:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 20 2023, 11:35 AM
kpn requested review of this revision.Jun 20 2023, 11:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 20 2023, 11:35 AM

The Attribute field isn't required to be unique. It's only unique for boolean features, but this emitter ignores non-boolean features so maybe that's ok?

pengfei accepted this revision.Jun 20 2023, 7:11 PM

Makes sense to me.

This revision is now accepted and ready to land.Jun 20 2023, 7:11 PM
craig.topper added inline comments.Jun 21 2023, 10:04 AM
llvm/include/llvm/TableGen/Record.h
2038

Probably could keep this in SubtargetEmitter.cpp? Doesn't seem generically useful.

This revision was automatically updated to reflect the committed changes.