On 28.08.2015 09:03, Josef Weidendorfer wrote: > This suggests we should document the difference between > START/STOP_INSTRUMENTAITON > and TOGGLE_COLLECT better.
Hmm, yes :) Any chance you can write something up in time for 3.11 ? > >> for (int i = 1; i <= 1000; ++i) { >> CALLGRIND_START_INSTRUMENTATION; >> n += i; >> CALLGRIND_STOP_INSTRUMENTATION; >> } > > With macros in C, the compiler can reorder stuff, so you may end up with > something like > >> for (int i = 1; i <= 1000; ++i) { >> n += i; >> CALLGRIND_START_INSTRUMENTATION; >> CALLGRIND_STOP_INSTRUMENTATION; >> } > Huh? CALLGRIND_START_INSTRUMENTATION expands into a statement sequence that includes __asm__ volatile("whatever" ::: "memory"); and GCC docs say: <quote> If your assembler instructions access memory in an unpredictable fashion, add 'memory' to the list of clobbered registers. </quote> Wouldn't that prevent the CALLGRIND_START_INSTRUMENTATION from being moved around? Reason being that the memory clobber might change the value of "i" in a way not visible to the compiler? Florian ------------------------------------------------------------------------------ _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users