GCC 内部:假的解引用在哪里被删除?

发布于 2024-08-18 14:40:15 字数 394 浏览 1 评论 0原文

表达式 &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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月寒剑心 2024-08-25 14:40:15

由于您已经熟悉 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文