Steven Bosscher <stevenb....@gmail.com> writes: > I am confused by the following code in > ifcvt.c:noce_mem_write_may_trap_or_fault_p(): > > static bool > noce_mem_write_may_trap_or_fault_p (const_rtx mem) > { > rtx addr; > > if (MEM_READONLY_P (mem)) > return true; > (...) > > addr = XEXP (mem, 0); > > /* Call target hook to avoid the effects of -fpic etc.... */ > addr = targetm.delegitimize_address (addr); > > while (addr) > switch (GET_CODE (addr)) > { > (...) case SYMBOL_REF: > if (SYMBOL_REF_DECL (addr) > && decl_readonly_section (SYMBOL_REF_DECL (addr), 0)) > return true; > > If decl_readonly_section (SYMBOL_REF_DECL (addr), 0) is true, I would > expect that MEM_READONLY_P is set, and the decl_readonly_section check > is never true. > > Is there a difference between "could be read-only" > (decl_readonly_section) and "is read-only" (MEM_READONLY_P)?
In principle, I agree that MEM_READONLY_P should be set if the address is based on a SYMBOL_REF and decl_readonly_section is true for the SYMBOL_REF. In practice I would not be in the least surprised if the two tests were not identical. There is a lot of code in the compiler that creates a MEM, and the functions to create a MEM do not check for a SYMBOL_REF for which decl_readonly_section is true. There are other triggers for MEM_READONLY_P, so it could turn out to be identical, but I would not be surprised if it isn't. If you are really curious it's probably worth adding a test there to see if it ever triggers--if the call to decl_readonly_section ever returns true. Ian