[llvm-dev] Help with bitcast instruction
Tim Northover via llvm-dev
llvm-dev at lists.llvm.org
Sun Mar 10 00:59:16 PST 2019
Hi Alberto,
> I would like to understand where bitcast is defined because it is not defined within libpng.
It's because the function (@png_set) has been defined to take one kind
of argument, but is being called with another. In this case the
difference seems to be whether it takes pointers to
%struct.png_struct_def or %struct.png_struct_def.68.
This kind of situation isn't terribly common, but can happen for
example in LTO where two modules are linked together, and one of them
only has an opaque handle for the type to hide the implementation
(e.g. from plain "struct png_struct_def;" in C). When that happens
LLVM can't merge the types, so it adds a numeric tag to one of them,
and then it has to insert bitcasts in the calls like this so that its
own type system works.
> I also noticed that the @ is not present, what does the missing @ mean? I guess it must be an LLVM function.
The @ is only used directly before a global variable (including a
declared/defined function). In this case it's buried, but it is there
(@png_set). In other cases, like when you call a function pointer, it
will be missing entirely.
Cheers.
Tim.
More information about the llvm-dev
mailing list