[PATCH] D21121: IR: Introduce llvm.type.checked.load intrinsic.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 13 15:47:39 PDT 2016
pcc added a comment.
> Could you elaborate on why this is necessary? It looks like the code generated in scanTypeCheckedLoadUsers could be just as well generated by the frontend. I must be missing something.
Do you mean that the frontend could generate code that looks like this:
vtable = p->vtable;
if (llvm.type.test(vtable, "P")) {
vtable->f(p, ...);
} else {
trap;
}
and that this pass could devirtualize this like so:
if (llvm.type.test(vtable, "P")) {
p::f(p, ...);
} else {
trap;
}
?
Unfortunately this doesn't give us exactly what we want here, as we want to eliminate the `llvm.type.test` call if (and only if) the call was devirtualized, i.e. we want the final code to look like this:
p::f(p, ...);
While it would be technically possible to implement a pass that performs such a transformation, that would have another problem: it would mean that the semantics of the `llvm.type.test` intrinsic would be defined by other uses of its argument (a sort of "action at a distance"), which would be unusual and difficult to specify. Such a semantics for `llvm.type.test` could also interfere with the diagnosing CFI modes, as we do actually want the intrinsic to perform an accurate type test in that case.
> This pass runs before LowerBitSets, right?
Yes.
http://reviews.llvm.org/D21121
More information about the llvm-commits
mailing list