LLVM输出结果与预期不符。

huangapple go评论98阅读模式
英文:

LLVM outputs differently than it should

问题

我对使用LLVM C API相当新,并且以前从未遇到过这个问题。从在线示例中,当它们使用LLVMIntTypeInContext创建LLVMTypeRef,然后使用LLVMPointerType时,它们得到一个干净的i16*类型,但我得到ptr
以下是参考代码:

LLVMTypeRef type = LLVMIntTypeInContext(context,16);
type = LLVMPointerType(type,0);

然后我只是打印模块。
我使用的是搭载M1芯片的MacOS和LLVM版本16.0.6。
有些人建议我安装更新版本的LLVM,因为之前我使用的是版本15,但没有任何改变。然后我尝试完全重新安装它,但没有改变。我还尝试彻底从我的Mac中删除它,然后重新安装它。什么都没用。有人可以帮我解决这个问题吗?

英文:

I am pretty new to using LLVM C API, and never have encountered this issue before. From examples, I seen online when they create a LLVMTypeRef using LLVMIntTypeInContext and then LLVMPointerType, they get a clean i16* type, but I get ptr
here is the reference code

LLVMTypeRef type = LLVMIntTypeInContext(context,16)
type = LLVMPointerType(type,0)

afterwards I just print the module.
I am using MacOs with M1 chip and LLVM version 16.0.6

Some people recommended me install the newer version of LLVM because before that I used version 15, nothing has changed. Then I tried to completely reinstall which changed nothing. I also tried to completely deleting it from my Mac and then install it. Nothing has worked. Can anyone please help me with my issue

答案1

得分: 1

LLVM将包含指向类型的所有指针类型替换为不透明指针类型。该指针类型表示为ptr

可以使用LLVM工具中的-opaque-pointers=0或clang中的-Xclang -no-opaque-pointers来禁用不透明指针模式。

有关更多信息,请查看:
https://llvm.org/docs/OpaquePointers.html

英文:

LLVM replaced all pointer types containing pointee type with an opaque pointer type. That pointer type is represented as ptr
> The opaque pointer mode can be disabled using -opaque-pointers=0 in LLVM tools like opt, or -Xclang -no-opaque-pointers in clang

For more info, check:
https://llvm.org/docs/OpaquePointers.html

huangapple
  • 本文由 发表于 2023年8月5日 05:28:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76839183.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定