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.
精彩评论