This is an archive of the discontinued LLVM Phabricator instance.

[MIPS] Check if register is non-null before calling isSuperOrSubRegisterEq (NFCI)
ClosedPublic

Authored by barannikov88 on May 23 2023, 10:04 PM.

Details

Summary

D151036 adds an assertions that prohibits iterating over sub- and
super-registers of a null register. This is already the case when
iterating over register units of a null register, and worked by
accident for sub- and super-registers.

Diff Detail

Event Timeline

barannikov88 created this revision.May 23 2023, 10:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2023, 10:04 PM
barannikov88 requested review of this revision.May 23 2023, 10:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2023, 10:04 PM

Rebase onto 8e16365c to make the bot green again

I noticed there are some lines like:

2955     unsigned TmpReg = DstReg;
2956     if (UseSrcReg &&
2957         getContext().getRegisterInfo()->isSuperOrSubRegisterEq(DstReg,
2958                                                                SrcReg)) {
2959       // If $rs is the same as $rd, we need to use AT.
2960       // If it is not available we exit.
2961       unsigned ATReg = getATReg(IDLoc);
2962       if (!ATReg)
2963         return true;
2964       TmpReg = ATReg;
2965     }

Is UseSrcReg OK for here?

I noticed there are some lines like:

2955     unsigned TmpReg = DstReg;
2956     if (UseSrcReg &&
2957         getContext().getRegisterInfo()->isSuperOrSubRegisterEq(DstReg,
2958                                                                SrcReg)) {
2959       // If $rs is the same as $rd, we need to use AT.
2960       // If it is not available we exit.
2961       unsigned ATReg = getATReg(IDLoc);
2962       if (!ATReg)
2963         return true;
2964       TmpReg = ATReg;
2965     }

Is UseSrcReg OK for here?

I honestly don't know :) Sounds reasonable, let's try it

Check UseSrcReg instead of SrcReg and rebase onto 8e16365c to make the bots happy

I agree with this patch, while I have no approval permission.

@MaskRay

@wzssyqa Thanks for the quick review!

This revision was not accepted when it landed; it landed in state Needs Review.May 24 2023, 2:58 AM
This revision was automatically updated to reflect the committed changes.
barannikov88 reopened this revision.May 24 2023, 3:01 AM

Whoops, I committed a change with wrong commit message referring to this review (copy&pasted) and the review was closed automatically >_<
Reopening

Revert to the correct revision

MaskRay accepted this revision.May 24 2023, 8:26 PM
This revision is now accepted and ready to land.May 24 2023, 8:26 PM