gpt4 book ai didi

llvm - LLVM 3.0 中是否有结构类型同构检查?

转载 作者:行者123 更新时间:2023-12-01 04:04:26 24 4
gpt4 key购买 nike

在 LLVM-3.0 中,命名结构始终是唯一的,并且与其他结构相同的结构的指针相等不起作用。来自他们的 blog entry on LLVM-3.0 types ,亮点是我的:

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).



这通过类型指针检查打破了类型相等性检查。
例如,haskell 包 llvm取决于 llvm 类型指针对于编译时类型检查和类型转换是否相等。

有没有办法检查两个结构是否同构(相同结构)?最好在 llvm-c api 中?

最佳答案

在 C++ API 中,StructType类(class)有

bool StructType::isLayoutIdentical(StructType *Other) const

此函数遍历 StructType 的元素以查看它们是否相等。

关于llvm - LLVM 3.0 中是否有结构类型同构检查?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10398746/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com