[llvm-dev] RFC: Absolute or "fixed address" symbols as immediate operands
Reid Kleckner via llvm-dev
llvm-dev at lists.llvm.org
Tue Oct 25 14:07:25 PDT 2016
On Tue, Oct 25, 2016 at 1:48 PM, Rafael EspĂndola via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> So, for the declaration, do you expect to know the value? If not just
> a declaration to a GlobalVariable should be sufficient.
>
No, the value will be discovered at link time, but we want instruction
selection to treat the symbol as an immediate, not a GlobalAddress that
will receive PIC and GOT treatment.
If we use a declaration as you suggest, this example will compile awkwardly:
@foo = external global i8
define i64 @addfoo(i64 %v) {
%cast = ptrtoint i8* @foo to i64
%v1 = add i64 %v, %cast
ret i64 %v1
}
The ideal code is:
addfoo:
leaq foo(%rdi), %rax
retq
Today we select:
addfoo:
addq foo at GOTPCREL(%rip), %rdi
movq %rdi, %rax
retq
We could use attributes to try to convince ISel not to form GlobalAddress
nodes, but we might also want to consider just adding a new kind of global.
Chris's proposal of giving this new globalconst pointer type seems like a
reasonable compromise to avoid disturbing the rest of LLVM. The ptrtoint
cast will go away when we build MI.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161025/6b909004/attachment.html>
More information about the llvm-dev
mailing list