문제

In LLVM-3.0, named structs are always unique and pointer equality with other structurally same structs does not work. From their blog entry on LLVM-3.0 types, the highlights are mine:

Identified structures are the kind we are talking about: they can have a name, and can have their body specified after the type is created. The identified structure is not uniqued with other structure types, which is why they are produced with StructType::create(...). Because identified types are potentially recursive, the asmprinter always prints them by their name (or a number like %42 if the identified struct has no name).

This breaks type equality checking by type pointer checking. For example, the haskell package llvm depends on llvm type pointers being equal for compile time type checks and type casts.

Is there any way to check for two structs being isomorphic(same structure)? Preferably in the llvm-c api?

도움이 되었습니까?

해결책

In the C++ API, the StructType class has

bool StructType::isLayoutIdentical(StructType *Other) const

This function iterates through the elements of the StructTypes to see if they're equal.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top