This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 11/18/13 04:08, Richard Biener wrote:
It's the nonnull attribute on memset. One thought would split the optimization into two parts. One which transforms *0 and the other which transforms calls/returns. Have the former enabled by -O2 the latter off for now. For the next release, both enabled by default at -O2.I'd say that turning memset (0, '\0', 0) into a trap is bad from a QOIperspective. Jeff, is there an easy way to avoid this? Testcase: void fn (void *addr, int a) { if (a == 0) addr = (void *)0; __builtin_memset (addr, '\0', a); } I wonder where in isolate-paths you check for builtins at all? ah, it's probably from the nonnull attribute on memset. Which also means that trying to catch this case reliably isn't going to work (you cannot prove the program has len == 0 in this case and conditionally not trapping would somewhat defeat the purpose of isolating this path)
Add distinct warnings for both cases, possibly enabled by -Wall (depends on the noise).
That gets most of the benefit now and gives a way for users to identify brokenness in their code.
Sadly, this feels a lot like -fstrict-aliasing did eons ago. Aggressive TBAA exposed all kinds problems and it took a lot of user (re)education to get them fixed.
jeff
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |