[PATCH] D18367: Introduce llvm.load.relative intrinsic.

John McCall via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 19:34:04 PDT 2016

rjmccall added a comment.

In http://reviews.llvm.org/D18367#381050, @pcc wrote:

> > Are you planning to store v-table entries relative to the v-table's address point rather than the address of the slot?
> Yes, exactly. Sorry if that wasn't clear before. On most architectures the vtable load can be expressed as a reg+imm load; we can achieve a shorter call sequence by using that register as an addend rather than having an additional immediate.

On ARM and AArch64, adjusting the v-table address to the slot address can be done with a pre-indexed load, so it doesn't really matter there.  I agree that it probably helps x86, though.  Somewhat amusing to think about x86 requiring more instructions to do something, though. :)

> > Even if so, can't that sort of further adjustment be trivially done by the caller instead of baking it into the intrinsic?



> We could certainly do it that way, but the problem with that is that I think it would make other parts of the compiler more complicated. For example, the whole-program virtual call optimizer would need to do more IR walking in order to discover the slot offset (which would now need to be present in two places in the IR and verified to be equal) and the call site.

Hmm.  Fair enough, I think I see your point.


More information about the llvm-commits mailing list