|
Message-ID: <20120824060611.GX27715@brightrain.aerifal.cx> Date: Fri, 24 Aug 2012 02:06:11 -0400 From: Rich Felker <dalias@...ifal.cx> To: musl@...ts.openwall.com Subject: Re: build musl with clang On Fri, Aug 24, 2012 at 11:58:51AM +0600, agent wrote: > 23.08.2012 23:55, Rich Felker пишет: > >The bug is that clang assumes the memory returned from malloc has > >indeterminate contents, which is only a valid assumption on a hosted > >implementation. On a freestanding one, malloc is just another ordinary > >function with no special semantics. Anyway, based on the wrong > >assumption, it optimizes out the zero-fill code that's of the form > > > >for (i=0; i<n; i++) if (mem[i]) mem[i] = 0; > > > >I am not willing to remove the if, because it serves a valuable > >purpose: it avoids writing to pages that are already all-zero, which > >in turn reduces swap pressure/dirty pages. > > > >Rich > even if it assumes the memory has indeterminate contents, > indeterminate isn't zero so i feel there is no real reason to wipe > the whole cycle out only because of if statement -- malloc does not > have to (and should not) zero fill the returned memory. Any use of indeterminate values results in UB, so the compiler would be just as free to omit no code at all for the function on a hosted implementation. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.