------- Comment #11 from jakub at gcc dot gnu dot org 2010-06-10 12:24 ------- I believe for GCC it shouldn't be hard to at least easily detect the used zero times case which happens very often in lost of code. asm ("... %2 ... " : "=m" (*p) : "m" (*p), "r" (p)); is just very common, the "=m" and "m" just tells gcc that the memory is used and might change. It would be even possible using a target hook to check whether it is used exactly once, furthermore in target specific proper way (say, on powerpc64 the check would be that there is exactly one use of the operand with U modifier, at most one with X modifier and exactly one another use, on ia64 it could be that there is exactly one use with P modifier and exactly one use another use, on the targets which print incdec in *print_*address it could be by default check for exactly one use of the operand. This is not going to be perfect, it would count uses in comments and also doesn't cover e.g. a single use in not always executed code (say the asm has conditional jump around a few insns and uses the mem in there), but could fix up significant amount of code in the wild.
-- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44492