[PATCH] D49403: More aggressively complete RecordTypes with Function Pointers

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 25 10:36:26 PDT 2018


rjmccall added a comment.

In https://reviews.llvm.org/D49403#1175350, @olga.chupina wrote:

> I should probably add one more example to explain my point of view.
>  Suppose we have an indirect call in the program and we need to know all possible goals for this indirect call. Then we would like to know that one of the structure fields is a function pointer and it can be a candidate for indirect call resolution.


I'm not making the connection you're trying to suggest, sorry.  So you have whole-program information, and you're looking at a particular indirect call, and you want to know where it can go more precisely than just "any function whose address has escaped".  What is the struct in this situation?

LLVM IR types are not accurate to the C type system, and the C type system does not allow you to know conclusively whether a function pointer is stored somewhere.  Even ignoring common extensions like allowing a function pointer to be represented in a `void*` (which is absolutely pervasive and relied upon by POSIX APIs), you can just store a function pointer value into a union member or some other kind of untyped/loosely-typed memory.  So any analysis that depends for correctness on identifying all IR types that could store a function pointer is just not going to work, at least for IR coming from C.


https://reviews.llvm.org/D49403





More information about the cfe-commits mailing list