This is an archive of the discontinued LLVM Phabricator instance.

[PPC64] Fix toc restore nops offset for V2 ABI
ClosedPublic

Authored by syzaara on Apr 20 2018, 11:20 AM.

Details

Summary

The PPC64 V2 ABI restores the toc base by loading from an offset of 24 from r1. This patch fixes the offset and updates the testcases from V1 to V2. It also issues an error when a nop is missing after a call to an external function.

Diff Detail

Event Timeline

syzaara created this revision.Apr 20 2018, 11:20 AM
ruiu accepted this revision.Apr 20 2018, 11:26 AM

LGTM with these fixes.

lld/ELF/InputSection.cpp
746

error() automatically adds "error: " at beginning of a message, so please remove it from your message. Error messages shouldn't end with a full stop.

If you flip the condition, you can reduce the nesting level like this.

if (BufLoc + 8 > BufEnd || read32(BufLoc + 4) != 0x60000000) {
  error(...);
  return;
}
write32(...)
This revision is now accepted and ready to land.Apr 20 2018, 11:26 AM

It would be nice to have a test similar to ppc64-error-toc-restore.s that makes sure we emit the error for a missing nop on a tail call as well.

This revision was automatically updated to reflect the committed changes.