This is an archive of the discontinued LLVM Phabricator instance.

WholeProgramDevirt: Add import/export support for targets without absolute symbol constants.
ClosedPublic

Authored by pcc on Sep 1 2017, 5:29 PM.

Details

Summary

Not all targets support the use of absolute symbols to export
constants. In particular, ARM has a wide variety of constant encodings
that cannot currently be relocated by linkers. So instead of exporting
the constants using symbols, export them directly in the summary.
The values of the constants are left as zeroes on targets that support
symbolic exports.

This may result in more cache misses when targeting those architectures
as a result of arbitrary changes in constant values, but this seems
somewhat unavoidable for now.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc created this revision.Sep 1 2017, 5:29 PM
eugenis added inline comments.Sep 5 2017, 2:36 PM
llvm/lib/LTO/LTO.cpp
233 ↗(On Diff #113627)

does this increase the summary size on x86, too?

pcc added inline comments.Sep 5 2017, 2:43 PM
llvm/lib/LTO/LTO.cpp
233 ↗(On Diff #113627)

Note that this is just for computation of the hash. If we were to serialize these out (see the FIXME in ModuleSummaryIndex.h) then I expect that we could arrange to write them out at the end of the record only if they are non-zero.

eugenis edited edge metadata.Sep 5 2017, 2:58 PM

Ok, looks fine to me.
Could you elaborate on the linker issue - is it that some of the uses of these constants can not be represented with existing relocation types? Or is it missing functionality in the existing linkers?

pcc added a comment.Sep 5 2017, 4:36 PM

Ok, looks fine to me.
Could you elaborate on the linker issue - is it that some of the uses of these constants can not be represented with existing relocation types? Or is it missing functionality in the existing linkers?

Some of the former, some of the latter. For CFI for example, the ROT instruction encodes the immediate as 5 bits split in two, and as far as I know there is no relocation that can encode that. For WholeProgramDevirt we will want to use LDR to read from the vtable, and for at least one of the LDR forms it looks like there is a R_ARM_THM_ABS5 relocation that could be relevant, but there is no toolchain support for it. http://llvm-cs.pcc.me.uk/?q=R_ARM_THM_ABS5

eugenis accepted this revision.Sep 11 2017, 2:28 PM
This revision is now accepted and ready to land.Sep 11 2017, 2:28 PM
This revision was automatically updated to reflect the committed changes.