shiva0217 added a comment. In D79378#4101829 <https://reviews.llvm.org/D79378#4101829>, @rjmccall wrote:
> In D79378#4101613 <https://reviews.llvm.org/D79378#4101613>, @shiva0217 wrote: > >> Hi, >> >> I have a question for the delete function call sinking in -Oz. >> >> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3690.pdf. >> According to 3.7.4.2/3 >> ` The value of the first argument supplied to a deallocation function may be >> a null pointer value; if so, and if the deallocation function is one >> supplied in the standard library, the call has no effect. Otherwise, the >> behavior is undefined` >> >> It seems the null checking can be skipped only when the delete is not from >> the standard library(have been overloaded by the user), isn't it? > > The paragraph you just quoted says that the deallocation functions provided > by the standard library are required have no effect on null pointers. That > means it's fine to call them with a null pointer even if the source wouldn't > normally execute that call. We could just insert these calls into random > other code if we wanted to. Is a null operand of delete in the source code no effect because there will be null pointer checking generated? Or the delete(null) in assembly code also valid? > As discussed in the original review, removing null checks around calls to > `operator delete` is rarely going to be a good code-speed optimization, but > it is a good code-size optimization, and `-Oz` in Clang is a request to > minimize code size even if it makes the code slower. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79378/new/ https://reviews.llvm.org/D79378 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits