This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Correctly use ELFv2 ABI on all OS's that use the ELFv2 ABI
ClosedPublic

Authored by brad on Feb 17 2023, 10:44 PM.

Details

Summary

I noticed D144232. This makes sure the ELFv2 ABI is utilized properly on all OS's that use the ELFv2 ABI.

Diff Detail

Event Timeline

brad created this revision.Feb 17 2023, 10:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 17 2023, 10:44 PM
brad requested review of this revision.Feb 17 2023, 10:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 17 2023, 10:44 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
brad updated this revision to Diff 498642.Feb 18 2023, 4:02 PM
dim accepted this revision.Feb 18 2023, 4:42 PM
dim added a subscriber: dim.

LGTM, some minor clang-format nits, but these aren't critical (to me at least :)

clang/lib/Basic/Targets/PPC.h
432

clang-format seems to want to format the if as:

if ((Triple.isOSFreeBSD() && (Triple.getOSVersion().empty() ||
                              Triple.getOSMajorVersion() >= 13)) ||
    Triple.isOSOpenBSD() || Triple.isMusl())

E,g. it groups the whole FreeBSD expression together. I didn't know it could do this, but it seems relatively clear.

llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
242

similarly for this one, clang-format likes to format it as:

if ((TT.isOSFreeBSD() &&
     (TT.getOSVersion().empty() || TT.getOSMajorVersion() >= 13)) ||
    TT.isOSOpenBSD() || TT.isMusl())
This revision is now accepted and ready to land.Feb 18 2023, 4:42 PM
dim added a reviewer: pkubaj.Feb 18 2023, 4:43 PM
brad updated this revision to Diff 498648.Feb 18 2023, 5:14 PM

reformatting.

brad marked 2 inline comments as done.Feb 18 2023, 5:15 PM
brad added inline comments.
clang/lib/Basic/Targets/PPC.h
432

clang-format seems to want to format the if as:

if ((Triple.isOSFreeBSD() && (Triple.getOSVersion().empty() ||
                              Triple.getOSMajorVersion() >= 13)) ||
    Triple.isOSOpenBSD() || Triple.isMusl())

E,g. it groups the whole FreeBSD expression together. I didn't know it could do this, but it seems relatively clear.

I can see both ways of doing things. I try to keep it as compact as possible. But I'll go with the suggested format.

nemanjai added inline comments.Feb 19 2023, 4:47 PM
clang/lib/Basic/Targets/PPC.h
430–432

I am generally not a fan of keeping multiple instances of a somewhat complex conditions in sync. I wonder if the community would be OK with one of:

  • Adding a static function in Triple.h to test this (static bool isPPCELFv2ABI(const Triple &))
  • Adding a member function Triple::isPPCELFv2ABI() (similar to Triple::isWatchABI())

Then of course, we can use that function in both places.

brad marked an inline comment as done.Feb 19 2023, 4:50 PM
brad added inline comments.
clang/lib/Basic/Targets/PPC.h
430–432

I am generally not a fan of keeping multiple instances of a somewhat complex conditions in sync. I wonder if the community would be OK with one of:

  • Adding a static function in Triple.h to test this (static bool isPPCELFv2ABI(const Triple &))
  • Adding a member function Triple::isPPCELFv2ABI() (similar to Triple::isWatchABI())

Then of course, we can use that function in both places.

Ultimately something like that would be better as it's used in 3 different spots.

brad updated this revision to Diff 498748.Feb 20 2023, 12:38 AM
dim accepted this revision.Feb 20 2023, 1:30 AM

Yeah, this looks quite a bit nicer, and should be more maintainable. Thanks.

pkubaj accepted this revision.Feb 20 2023, 5:54 AM
nemanjai accepted this revision.Feb 20 2023, 6:44 AM

Thanks for doing this. LGTM.

This revision was landed with ongoing or failed builds.Feb 20 2023, 3:11 PM
This revision was automatically updated to reflect the committed changes.