This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Handle s_branch to another section.
ClosedPublic

Authored by abidh on Jul 10 2021, 9:47 AM.

Details

Summary

Currently, if target of s_branch instruction is in another section, it will fail with the error of undefined label. Although in this case, the label is not undefined but present in another section. This patch tries to handle this issue. So while handling fixup_si_sopp_br fixup in getRelocType, if the target label is undefined we issue an error as before. If it is defined, a new relocation type R_AMDGPU_REL16 is returned.

This issue has been reported in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100181 and https://bugs.llvm.org/show_bug.cgi?id=45887. Before https://reviews.llvm.org/D79943, we used to get an crash for this scenario. The crash is fixed now but the we still get an undefined label error. Jumps to other section can arise with hold/cold splitting.

A patch to handle the relocation in lld will follow shortly.

Diff Detail

Event Timeline

abidh created this revision.Jul 10 2021, 9:47 AM
abidh requested review of this revision.Jul 10 2021, 9:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2021, 9:47 AM
arsenm accepted this revision.Jul 12 2021, 5:41 PM

LGTM with nit

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
87

No else after return

This revision is now accepted and ready to land.Jul 12 2021, 5:41 PM
abidh updated this revision to Diff 358207.Jul 13 2021, 2:42 AM

Remove else after the return.

abidh updated this revision to Diff 358213.Jul 13 2021, 3:10 AM

Rebase. One of the test file has moved in the repo so updated the patch accordingly.

This revision was landed with ongoing or failed builds.Jul 13 2021, 4:21 AM
This revision was automatically updated to reflect the committed changes.