Shawn Landden via llvm-dev
2019-Feb-24 17:17 UTC
[llvm-dev] RFC: avoid relocations with PC
When PIC code uses a string, this creates a relocation that slows down program startup time. As long as the string is in the same compilation unit as the PIC code this relocation is unnecessary, as the offset of the compiled unit is stored in the program counter, and can be accessed by a stored subtraction/addition. This would mean more instructions at the call site, so the details I would image would require some careful coordination between llvm and lld. I have a bug for this: https://bugs.llvm.org/show_bug.cgi?id=39049 and would greatly appreciate feedback, and pointers on how to do this. Thanks! Shawn Landden -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190224/1615548e/attachment.html>
Joerg Sonnenberger via llvm-dev
2019-Feb-25 00:01 UTC
[llvm-dev] RFC: avoid relocations with PC
On Sun, Feb 24, 2019 at 11:17:57AM -0600, Shawn Landden via llvm-dev wrote:> When PIC code uses a string, this creates a relocation that slows down > program startup time. As long as the string is in the same compilation unit > as the PIC code this relocation is unnecessary, as the offset of the > compiled unit is stored in the program counter, and can be accessed by a > stored subtraction/addition. This would mean more instructions at the call > site, so the details I would image would require some careful coordination > between llvm and lld.This is happening already given support from the target architecture and code model. Compile const char *f(void) { return "foo"; } for x86-64 with -fPIC for example (i.e. small code model). Joerg