1

According to https://llvm.org/docs/LangRef.html#opaque-structure-types

Opaque structure types are used to represent structure types that do not have a body specified. This corresponds (for example) to the C notion of a forward declared structure. They can be named (%X) or unnamed (%52).

Seems straightforward enough, but one thing I'm trying to figure out is this. Suppose we have two opaque types:

%X = type opaque
%Y = type opaque

Does LLVM ever care about the fact that these are two different types? Is there any scenario in which substituting X for Y would cause different code to be generated? One possibility that comes to mind is type-based alias analysis, but then, it is not possible to dereference an opaque type, so it looks like there is no way for it to make a difference. Am I missing anything?

rwallace
  • 31,405
  • 40
  • 123
  • 242
  • 1
    What you miss is perhaps that LLVM invites you to write your own passes. The frontend I work on generates code and uses a pass manager to run LLVM-provided passes and also some custom passes, and some of those passes distinguish between different opaque types. They can do that because they were written along with the frontend that generates them. I believe many compilers do this, more or less, in various ways. – arnt Dec 25 '21 at 11:32

0 Answers0