|
|
Descriptionclang/win: Prevent clang from optimizing away a malloc in a test.
Similar to e.g. https://codereview.chromium.org/8429008 and
https://codereview.chromium.org/8429008 .
BUG=448935
R=scottmg@chromium.org, wfh@chromium.org
Committed: https://chromium.googlesource.com/chromium/src/+/33fd64cf5b5e6cff7c96bd74051a0494d45b879a
Patch Set 1 #
Total comments: 4
Patch Set 2 : spellz #Messages
Total messages: 15 (3 generated)
thakis@chromium.org changed reviewers: + wfh@chromium.org
scottmg@chromium.org changed reviewers: + scottmg@chromium.org
lgtm https://codereview.chromium.org/868743003/diff/1/base/security_unittest.cc File base/security_unittest.cc (right): https://codereview.chromium.org/868743003/diff/1/base/security_unittest.cc#ne... base/security_unittest.cc:45: // Without the |volatile|, clang optimizez away the allocation. optimizes
https://codereview.chromium.org/868743003/diff/1/base/security_unittest.cc File base/security_unittest.cc (right): https://codereview.chromium.org/868743003/diff/1/base/security_unittest.cc#ne... base/security_unittest.cc:45: // Without the |volatile|, clang optimizez away the allocation. ah. interesting. We actually have HideValueFromCompiler below whose purpose is to solve this generically. Perhaps HideValueFromCompiler could be changed to understand clang, and then used here instead?
(It's interesting that `malloc()` isn't considered to have side-effects, I wouldn't have guess that was allowed.)
https://codereview.chromium.org/868743003/diff/1/base/security_unittest.cc File base/security_unittest.cc (right): https://codereview.chromium.org/868743003/diff/1/base/security_unittest.cc#ne... base/security_unittest.cc:45: // Without the |volatile|, clang optimizez away the allocation. On 2015/01/22 19:46:45, Will Harris wrote: > ah. interesting. We actually have HideValueFromCompiler below whose purpose is > to solve this generically. Perhaps HideValueFromCompiler could be changed to > understand clang, and then used here instead? What's wrong with volatile? That's kind of the language-supported way of doing this (and also what we use in other files doing similar things, see links to other cls in the cl description.) https://codereview.chromium.org/868743003/diff/1/base/security_unittest.cc#ne... base/security_unittest.cc:45: // Without the |volatile|, clang optimizez away the allocation. On 2015/01/22 19:46:21, scottmg wrote: > optimizes Done.
On 2015/01/22 19:48:31, Nico wrote: > https://codereview.chromium.org/868743003/diff/1/base/security_unittest.cc > File base/security_unittest.cc (right): > > https://codereview.chromium.org/868743003/diff/1/base/security_unittest.cc#ne... > base/security_unittest.cc:45: // Without the |volatile|, clang optimizez away > the allocation. > On 2015/01/22 19:46:45, Will Harris wrote: > > ah. interesting. We actually have HideValueFromCompiler below whose purpose > is > > to solve this generically. Perhaps HideValueFromCompiler could be changed to > > understand clang, and then used here instead? > > What's wrong with volatile? That's kind of the language-supported way of doing > this (and also what we use in other files doing similar things, see links to > other cls in the cl description.) Looking at the uses of HideValueFromCompiler(), it's usually not used with a decl, so volatile can't be used easily there. But here, just making the decl volatile seems like the right thing to do to me.
On 2015/01/22 19:48:31, Nico wrote: > What's wrong with volatile? That's kind of the language-supported way of doing > this (and also what we use in other files doing similar things, see links to > other cls in the cl description.) okay, the HideValueFromCompiler must be there specifically for a gcc issue where volatile isn't enough. I can chat to jln@ who added this extra wrapper and make sure it's still needed in the latest gccs
you wait a long time for an lgtm then two come along at the same time. lgtm
> I can chat to jln@ who added this extra wrapper and make sure it's still needed I can believe it's needed in the below, but it probably isn't needed here. On 2015/01/22 19:51:00, Will Harris wrote: > you wait a long time for an lgtm then two come along at the same time. Yeah, what's up with having to wait 5 minutes for a review! ;-) > lgtm Thanks!
The CQ bit was checked by thakis@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/868743003/20001
Message was sent while issue was closed.
Patchset 2 (id:??) landed as https://crrev.com/33fd64cf5b5e6cff7c96bd74051a0494d45b879a Cr-Commit-Position: refs/heads/master@{#312673}
Message was sent while issue was closed.
Committed patchset #2 (id:20001) manually as 33fd64cf5b5e6cff7c96bd74051a0494d45b879a (presubmit successful). |