[llvm-dev] Functions have two types, one can be mutated but not the other

David Blaikie via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 19 15:35:41 PST 2016


On Tue, Nov 24, 2015 at 9:25 AM, Andy Ayers via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Function has its own FunctionType* member as well as a Type* member that
> it inherits from GlobalValue. The latter can be mutated but not the former,
> leading to potential strange inconsistencies.
>
>
>
> While I realize using mutateType is probably going to trigger a bunch of
> “you’re doing it wrong” replies, it seems like mutateType, as a necessary
> evil, should be virtual and do the right wrong thing for Functions too.
>
>
>
> Thoughts?
>

I've been perpetrating some of this for the typeless/opaque pointer IR
stuff (some details here: https://www.youtube.com/watch?v=OWgWDx_gB1I - or
on a few threads on llvm-dev).

I got rid of that extra one in Function - thanks for noticing.

If I recall correctly, even before my work, it wasn't possible to rely
solely on mutateType of the operands  so various special cases have been
added (ValueMapper.cpp is a good example of some of these special cases)

I'm not sure why those issues might not have come up when dealing with
Globals. Perhaps you have some examples (eg: linking bitcode with globals -
where the value type gets out of sync with the pointer type? Maybe if we
add some more assertions in to check the two values are in sync we'd find
cases where they've gotten out of sync?)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160119/eeaff078/attachment.html>


More information about the llvm-dev mailing list