GCC 内部:假的解引用在哪里被删除?
表达式 &ptr->fld
并不表示取消引用,而是应将其视为 (uint32_t)ptr + offsetof (ptr, fld)
。我确信 GCC 会进行这种简化,但我找不到代码中的位置。
上面的内容最终在 AST 中为 ADDR_EXPR(COMPONENT_REF (INDIRECT_REF (ptr), fld))
,但在某些时候它应该进行并简化。在查找了 gcc 树中几乎所有出现的 ADDR_EXPR、COMPONENT_REF 和 INDIRECT_REF 后,我无法找到位置。有什么想法吗?
请注意,我曾尝试向海湾合作委员会人员寻求帮助。一般来说,它们没什么帮助,但这里的人可能知道答案。如果这是一个糟糕的问题,我会理解它是否已关闭。
The expression &ptr->fld
doesn't represent a dereference, instead it should be treated as (uint32_t)ptr + offsetof (ptr, fld)
. I am certain that GCC does this simplification, but I cannot find where in the code.
The above ends up as ADDR_EXPR(COMPONENT_REF (INDIRECT_REF (ptr), fld))
in the AST, but at some point it should go through and simplify it. Having looked up almost every occurrence of ADDR_EXPR, COMPONENT_REF, and INDIRECT_REF in the gcc tree, I'm having trouble discovering where. Any ideas?
Note that I've tried seeking out help from GCC people. In general they're pretty unhelpful, but people here may know the answer. If this is a bad question I'll understand if it's closed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您已经熟悉 GCC 的 AST,因此找到答案的一种方法是使用
gcc -fdump-tree-all -fdump-rtl-all
生成所有树和 RTL 转储,然后执行对它们进行二分搜索以定位进行转换的通道。Since you are already familiar with the AST of GCC, one way to find out would be to produce all tree and RTL dumps with
gcc -fdump-tree-all -fdump-rtl-all
and then do a binary search through them to localize the pass which does the transformmation.