This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC][NFC] Don't need to and instruction with inverse of mask.
AbandonedPublic

Authored by sfertile on Jun 3 2020, 9:02 AM.

Details

Summary

The bits to be relocated should already contain all zeros, no need to and the call instructions with the inverse mask before relocating.

Diff Detail

Event Timeline

sfertile created this revision.Jun 3 2020, 9:02 AM
MaskRay added inline comments.Jun 3 2020, 9:27 AM
lld/ELF/Arch/PPC64.cpp
976

This existing code have one fewer assumption. What's the motivation behind the change?

sfertile added inline comments.Jun 3 2020, 1:44 PM
lld/ELF/Arch/PPC64.cpp
976

The motivation is consistency: We don't zero out the bits before writing them in the handling of any of the other relocations, we assume the bits to be relocated already contain zeros.

MaskRay accepted this revision.Jun 3 2020, 2:14 PM

Looks great!

This revision is now accepted and ready to land.Jun 3 2020, 2:14 PM
MaskRay added a comment.EditedJun 12 2020, 12:47 PM

Shall we mask out the bits (keep existing (read32(loc) & ~mask))? If other relocations don't behave this way, let's fix it. Writing zeros to the bits is a courtesy of the assembly but should we make use of the assumption? PPC64 is a RELA target and for an RELA target the implicit addend should be relied upon. AArch64.cpp masks out the bits as well.

This revision now requires review to proceed.Jun 12 2020, 12:50 PM

Cleared the LGTM state.

Shall we mask out the bits (keep existing (read32(loc) & ~mask))? If other relocations don't behave this way, let's fix it. Writing zeros to the bits is a courtesy of the assembly but should we make use of the assumption? PPC64 is a RELA target and for an RELA target the implicit addend should be relied upon. AArch64.cpp masks out the bits as well.

My concern was how the linker being nice lead to a misunderstanding of how to encode an instruction. I've left a more detailed comment in the PCREL34 review so we can keep the discussion there and I can either abandon this or commit it depending on which way the discussion goes.

sfertile abandoned this revision.Jun 23 2020, 7:17 AM

Abandoning based on the discussion in D81457.