On Wed, Mar 06, 2019 at 10:15:33AM -0700, Martin Sebor wrote: > I read through this thread but I'm not sure I understand the problem > (or really the tree sharing business -- different GIMPLE statements > sharing the same tree node?) > > Is the problem here that the checking computes a checksum of the bits > in a tree node before folding and compares it to a checksum after > folding and setting the NO_WARNING bit in between causes the checking > to fail? > > If that's accurate, if this patch is not the right fix, what would be?
The --enable-checking=fold is an attempt to find bugs in fold and friends. Unlike the gimplifier, which is destructive on the trees passed to it (and that is why e.g. function bodies are unshared before being passed to the gimplifier), fold is invoked often by the FE and trees can be heavily shared at that point, so if fold modifies the arguments passed to it rather than creating new trees, it could modify some other tree in the same (or another) function. fold_checksum_tree has some exceptions on what is allowed to change, e.g. the various caches of types etc. My patch has treated the TREE_NO_WARNING flag similarly to that, as an exception, but Richard expressed the opinion that perhaps that is not the right thing and we should instead unshare trees containing it if we want to set TREE_NO_WARNING. That would mean either don't warn from within the folder (e.g. warn during gimplification or gimple-fold instead), or unshare. Jakub