开发者

GCC internals: Where are fake dereferences removed?

开发者 https://www.devze.com 2022-12-17 05:27 出处:网络
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

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 tro开发者_高级运维uble 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消