On Tue, Feb 09, 2021 at 03:00:20PM -0500, Jason Merrill wrote: > > With -fno-delete-null-pointer-checks which is e.g. implied by > > -fsanitize=undefined or default on some embedded targets, the middle-end > > folder doesn't consider addresses of global VAR_DECLs to be non-NULL, as one > > of them could have address 0. > > Hmm, are these VAR_DECLs going into the symtab? That seems undesirable.
They are not in the symtab from the C++ FE. And we don't allow those VAR_DECLs or their addresses to leak into the IL anyway. But, they are TREE_STATIC because pretending they are automatic didn't really work (e.g. address of automatic variables is not a constant expression). The generic folding code uses maybe_nonzero_address predicate which apprently creates a symtab entry for them but as nothing uses them they won't be emitted. If we wanted to avoid that, we'd need to either add some generic VAR_DECL bit for those vars or add a target hook that would return true for them and then handle them in the middle-end. Jakub