This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Default HBC/MOPS features in clang
ClosedPublic

Authored by tyb0807 on Feb 18 2022, 12:10 AM.

Details

Summary

This implements minimum support in clang for default HBC/MOPS features
on v8.8-a/v9.3-a or later architectures.

Diff Detail

Event Timeline

tyb0807 created this revision.Feb 18 2022, 12:10 AM
tyb0807 requested review of this revision.Feb 18 2022, 12:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 18 2022, 12:10 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
463–482

Can we reuse ItBegin and ItEnd here rather than Features.begin() and Features.end()?

465–474

Is it possible to re-use some of the many calls to std::find (L395-403)? Seems like we re-scan the feature list A LOT.

tyb0807 updated this revision to Diff 410225.Feb 20 2022, 11:21 PM

Cache architecture feature to avoid scanning the feature list over and over again.

tyb0807 marked 2 inline comments as done.Feb 20 2022, 11:29 PM
tyb0807 added inline comments.
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
463–482

This is not relevant anymore, but for the initial code, I guess we can't reuse ItBegin/End because Features has been changed since then (a lot of push_back). The reason why we need to keep these default features (+hbc, +mops, ...) right after the architecture feature is that we want to be able to disable the default features X if +noX option is given in the command line, knowing that +noX features will come after the architecture feature in the Features list.

465–474

I cached the architecture feature when it is defined to avoid these calls to std::find.

tyb0807 marked 2 inline comments as done.
tmatheson requested changes to this revision.Feb 25 2022, 6:53 AM
tmatheson added inline comments.
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
265

Looks like you could do AF = Features.back() below all these if/else conditions (where it is first used) based on the value of success. Maybe there is no need to pass it into getAArch64MicroArchFeaturesFromMcpu and the other functions?

Adding an extra output parameter to each of these functions (which duplicates an existing output parameter) seems unnecessary and makes the interfaces more complicated.

This revision now requires changes to proceed.Feb 25 2022, 6:53 AM
tyb0807 added inline comments.Feb 25 2022, 7:12 AM
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
265

we can't do AF = Features.back() below all the if/else conditions because getAArch64MicroArchFeaturesFromM* adds (usually) the architecture feature first, followed by a bunch of other features, so when it returns, Features.back() is not the architecture feature anymore.

I see your point about complicating the interfaces, maybe @nickdesaulniers can help us here?

tyb0807 updated this revision to Diff 412010.Mar 1 2022, 1:35 AM

Taking into account remarks from @tmatheson, I'm reverting my latest changes
consisting in caching architecture feature into a variable, which makes the
getAArch64ArchFeaturesFrom* interfaces more complicated.

I'd propose we move forward with this patch, and the performance issue raised by
@nickdesaulniers will be addressed properly in a separate one.

tyb0807 marked an inline comment as done.Mar 1 2022, 1:36 AM
tmatheson accepted this revision.Mar 1 2022, 4:32 AM

LGTM, please give @nickdesaulniers some time to respond though. I do agree that iterating over the features repeatedly is less than ideal, but also that this patch is probably not the place to try to fix it.

This revision is now accepted and ready to land.Mar 1 2022, 4:32 AM
nickdesaulniers accepted this revision.Mar 1 2022, 11:18 AM

LGTM, please give @nickdesaulniers some time to respond though. I do agree that iterating over the features repeatedly is less than ideal, but also that this patch is probably not the place to try to fix it.

I'm not exactly thrilled about continuing to kick the can down the road on this; consider making a child revision that fixes that first, then landing this patch. Otherwise that never gets cleaned up.

clang/lib/Driver/ToolChains/Arch/AArch64.cpp
468–480

Is Pos ever read later, or simply compared to std::end(Features)? If not, consider simplifying removing Pos outright and simply calling std::find_first_of in an if predicate.

This revision was landed with ongoing or failed builds.Apr 2 2022, 6:56 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 2 2022, 6:57 AM
Herald added a subscriber: MaskRay. · View Herald Transcript