public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/39612] [4.4/4.5/4.6/4.7 Regression] LIM inserts loads from uninitialized local memory Date: Tue, 17 Jan 2012 11:03:00 -0000 [thread overview] Message-ID: <bug-39612-4-WIwDo3aoUf@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-39612-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39612 --- Comment #16 from rguenther at suse dot de <rguenther at suse dot de> 2012-01-17 10:40:31 UTC --- On Tue, 17 Jan 2012, rakdver at gcc dot gnu.org wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39612 > > --- Comment #14 from Zdenek Dvorak <rakdver at gcc dot gnu.org> 2012-01-17 10:19:01 UTC --- > > > Also, the warning is at least morally right. If R <= 1, the original code will > > > pass inter to foo uninitialized, which probably is not intended. So, the right > > > thing to do could be issuing "may be used uninitialized" warning instead of "is > > > used uninitialized" one. > > > > Yes, but the point is that without the loop header copy we insert the > > loads and stores from/to inter in a path that is executed even when > > R <= 1 and thus the loop is not executed at all, and we warn about > > the inserted loads - not about the final one. Modified testcase: > > I realize that; making the warning to point to the right line would be somewhat > difficult, I guess. Yeah. > > For the store data-race consider > > > > int inter[3]; > > void > > f2 (int R) > > { > > int i; > > > > for (i = 1; i < R; i++) > > { > > inter[0] = 1; > > inter[1] = 1; > > inter[2] = 1; > > } > > } > > > > where inter is protected by a mutex, but only if R > 1. We still > > insert loads/stores on paths that are executed when the loop is not > > entered: > > Which is to be expected, as long as inter is not volatile. Store motion (and > cse, ...) will cause this kind of problems, this does not seem to be anything > specific to the testcase in question. If you have something like > > for (i = 1; i < R; i++) > { > lock (); > do something with inter[1] > unlock (); > } > > LSM will move inter[1] to a temporary variable regardless of the locks, which > will cause race conditions with other threads (and whether loop header is > copied or not is irrelevant). I think for the explicit lock code we are safe because we consider the lock/unlock calls to alias inter[] so we cannot SM it. In the light of the C++11 memory model we probably have to do something about even non-volatile accesses. I suppose we cannot easily detect at the moment if the loop has its header copied, thus, is do {} while style? We're using ref_always_accessed_p for the trapping insns issue, we could extend that to cover all global memory accesses - but I suppose that would pessimize things if ref_always_accessed_p isn't very good.
next prev parent reply other threads:[~2012-01-17 10:49 UTC|newest] Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-39612-4@http.gcc.gnu.org/bugzilla/> 2010-10-01 11:57 ` [Bug tree-optimization/39612] [4.3/4.4/4.5/4.6 " jakub at gcc dot gnu.org 2011-04-16 10:26 ` [Bug tree-optimization/39612] [4.3/4.4/4.5/4.6/4.7 " jakub at gcc dot gnu.org 2012-01-16 13:43 ` [Bug tree-optimization/39612] [4.4/4.5/4.6/4.7 " rguenth at gcc dot gnu.org 2012-01-16 16:43 ` rakdver at gcc dot gnu.org 2012-01-17 10:09 ` rguenth at gcc dot gnu.org 2012-01-17 10:40 ` rakdver at gcc dot gnu.org 2012-01-17 10:53 ` jakub at gcc dot gnu.org 2012-01-17 11:03 ` rguenther at suse dot de [this message] 2012-01-17 11:08 ` rakdver at gcc dot gnu.org 2012-03-13 13:16 ` [Bug tree-optimization/39612] [4.5/4.6/4.7/4.8 " jakub at gcc dot gnu.org 2012-07-02 11:29 ` rguenth at gcc dot gnu.org 2013-04-12 15:16 ` [Bug tree-optimization/39612] [4.7/4.8/4.9 " jakub at gcc dot gnu.org 2014-03-17 10:51 ` rguenth at gcc dot gnu.org 2014-03-17 10:53 ` rguenth at gcc dot gnu.org 2014-03-17 10:53 ` rguenth at gcc dot gnu.org 2014-06-12 13:43 ` [Bug tree-optimization/39612] [4.7/4.8/4.9/4.10 " rguenth at gcc dot gnu.org 2014-06-30 6:57 ` [Bug tree-optimization/39612] [4.8/4.9/4.10 " law at redhat dot com 2014-12-19 13:35 ` [Bug tree-optimization/39612] [4.8/4.9/5 " jakub at gcc dot gnu.org 2015-06-23 8:18 ` [Bug tree-optimization/39612] [4.8/4.9/5/6 " rguenth at gcc dot gnu.org 2015-06-26 20:06 ` [Bug tree-optimization/39612] [4.9/5/6 " jakub at gcc dot gnu.org 2015-06-26 20:34 ` jakub at gcc dot gnu.org 2020-03-12 11:58 ` [Bug tree-optimization/39612] [8/9 " jakub at gcc dot gnu.org 2020-04-30 9:22 ` rguenth at gcc dot gnu.org 2020-04-30 12:21 ` rguenth at gcc dot gnu.org 2020-05-04 12:15 ` cvs-commit at gcc dot gnu.org 2020-05-04 12:16 ` rguenth at gcc dot gnu.org 2020-05-05 12:32 ` tnfchris at gcc dot gnu.org 2020-05-05 12:39 ` rguenther at suse dot de 2020-05-05 12:48 ` tnfchris at gcc dot gnu.org 2020-05-05 22:43 ` joseph at codesourcery dot com 2022-04-22 4:43 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-39612-4-WIwDo3aoUf@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).