[cfe-dev] RFC: do not optimize on basis of __attribute__((nonnull)) in glibc headers

Hal Finkel via cfe-dev cfe-dev at lists.llvm.org
Tue Jan 3 15:29:40 PST 2017


On 01/03/2017 05:14 PM, Chandler Carruth wrote:
> On Tue, Jan 3, 2017 at 3:10 PM Hal Finkel via cfe-dev 
> <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote:
>
>     On the one hand, GCC has already started optimizing based on the
>     nonnull attribute on memcpy, and so that ship has sailed.
>
> I know of a large number of libraries that only behave correctly with 
> recent GCCs by using the flag Eli mentioned to disable all nonnull 
> optimizations wholesale. =/

I know of some too.

>
> If the standards committees actually change their mind here, I think 
> we could reasonably enable exactly this flag for Clang and LLVM when 
> built with a GCC version not implementing the fix.
>
> And even if not, even if we do actually have to fix all of our code to 
> work in the face of those optimizations, I at least have a large body 
> of users that aren't sure they will ever finish fixing all of these 
> issues. They don't have any good way to test and discover *all* of 
> them, only the ones hit in code paths today.

I suspect that essentially everyone with a non-trivially-sized codebase 
is in this boat.

> So I'd still like to give them a toolchain that will protect the 
> places in their software where they erroneously relied on a guarantee 
> not provided and have no tests or ability to go and fix.

This definitely seems useful.

  -Hal

>
> -Chandler

-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170103/8df4431d/attachment.html>


More information about the cfe-dev mailing list