GCC internal components: where are the fakes fixed?

The expression &ptr->fld not an dereference, instead it should be considered as (uint32_t)ptr + offsetof (ptr, fld) . I'm sure GCC makes this simplification, but I cannot find where in the code.

The above ends up as ADDR_EXPR(COMPONENT_REF (INDIRECT_REF (ptr), fld)) in AST, but at some point it should go through and simplify it. Having looked at almost all cases of ADDR_EXPR, COMPONENT_REF and INDIRECT_REF in the gcc tree, I find it hard to find where. Any ideas?

Please note that I tried to find help from the GCC people. In general, they are pretty worthless, but people here may know the answer. If this is a bad question, I will understand if it will be closed.

+4
source share
1 answer

Since you are already familiar with AST GCC, one way to find out would be to create all the tree and RTL dumps using gcc -fdump-tree-all -fdump-rtl-all , and then do a binary search through them to localize the passage that performs the conversion.

+1
source

All Articles