This is an archive of the discontinued LLVM Phabricator instance.

[NFC][AsmPrinter] Use std::visit in constructVariableDIEImpl
ClosedPublic

Authored by scott.linder on Aug 23 2023, 3:41 PM.

Details

Summary

This potentially has a slightly positive performance impact, as
std::visit can be implemented as a switch-like jump rather than
a series of ifs.

More importantly, the reader can be confident is no overlap between the
cases.

Diff Detail

Event Timeline

scott.linder created this revision.Aug 23 2023, 3:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2023, 3:41 PM
scott.linder requested review of this revision.Aug 23 2023, 3:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2023, 3:41 PM
fdeazeve accepted this revision.Aug 25 2023, 11:13 AM
fdeazeve added inline comments.
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
776

What do you think of implementing each of the visitors as a private member of DwarfCompileUnit?
I personally think this function could benefit from being split into different functions for readability, but this is a larger refactor.

This revision is now accepted and ready to land.Aug 25 2023, 11:13 AM
scott.linder added inline comments.Aug 25 2023, 12:41 PM
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
776

I definitely considered it, and agree it is worthwhile!

The whole series was an attempt to keep the changes gradual and understandable, and to leave open the option to drop things piecemeal. I try to assume the original intent has some rationale I am not considering, as that is often the case anyway (a lot of smart, dedicated people have contributed here) and I always worry that I'm changing things just to change them.

Hearing you come to the same conclusion makes me confident it is an improvement, though, so I will post a follow up!

This revision was landed with ongoing or failed builds.Sep 11 2023, 10:33 AM
This revision was automatically updated to reflect the committed changes.