This is an archive of the discontinued LLVM Phabricator instance.

[Sparc] Implement BFD_RELOC_NONE
ClosedPublic

Authored by ro on Jan 25 2022, 5:34 AM.

Details

Summary

instrprof-icall-promo.test FAILs on Solaris/sparcv9:

Profile-sparc :: instrprof-icall-promo.test
Profile-sparcv9 :: instrprof-icall-promo.test

when compiling compiler-rt/test/profile/Inputs/instrprof-icall-promo_2.cpp with

fatal error: error in backend: Relocation for CG Profile could not be created: unknown relocation name

This happens because the Sparc backend doesn't implement BFD_RELOC_NONE. This patch fixes that, following what X86 does.

Tested on sparcv9-sun-solaris2.11.

Diff Detail

Event Timeline

ro created this revision.Jan 25 2022, 5:34 AM
ro requested review of this revision.Jan 25 2022, 5:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2022, 5:34 AM

The changes look good. adjustFixupValue may or may not need FK_NONE, depending on how it is called in various targets.

Can you add a test like test/MC/RISCV/reloc-directive.s ?

ro added a comment.Jan 27 2022, 4:41 AM

The changes look good. adjustFixupValue may or may not need FK_NONE, depending on how it is called in various targets.

I've removed the handling and found no ill effect.

Can you add a test like test/MC/RISCV/reloc-directive.s ?

Done now: I'd initially been lazy, following several other targets that didn't have testcases either.

llvm/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp
74

I didn't: while clang-format-diff.py does make that change,
it causes that single case to diverge from all others.

ro updated this revision to Diff 403598.Jan 27 2022, 4:43 AM
    • Incorporate review comments.
  • Add testcase.
MaskRay accepted this revision.Jan 27 2022, 11:02 AM

Thanks!

This revision is now accepted and ready to land.Jan 27 2022, 11:02 AM

Done now: I'd initially been lazy, following several other targets that didn't have testcases either.

Not the targets that I have added the functionality for. Tests prevent regression.

ro added a comment.Jan 28 2022, 1:40 AM

Done now: I'd initially been lazy, following several other targets that didn't have testcases either.

Not the targets that I have added the functionality for. Tests prevent regression.

Indeed: investigating the objects resulting from the testcase found a couple of issues with LLVM Sparc reloc handling (unrelated to this patch)
that I mean to address separately.

This revision was landed with ongoing or failed builds.Jan 28 2022, 1:45 AM
This revision was automatically updated to reflect the committed changes.