Bug 47900 - Missed optimization with LTO
Summary: Missed optimization with LTO
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: lto, missed-optimization
Depends on:
Blocks:
 
Reported: 2011-02-26 04:40 UTC by Dmitry Gorbachev
Modified: 2013-02-07 00:13 UTC (History)
0 users

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail: 4.5.3, 4.6.0
Last reconfirmed: 2011-02-27 15:13:22


Attachments
Testcase (321 bytes, text/plain)
2011-02-26 04:40 UTC, Dmitry Gorbachev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Gorbachev 2011-02-26 04:40:13 UTC
Created attachment 23474 [details]
Testcase
Comment 1 Richard Biener 2011-02-27 15:13:22 UTC
I fail to see what the missed optimization is, can you try to explain?
Comment 2 Dmitry Gorbachev 2011-02-27 19:57:01 UTC
A null pointer check (... && ! &p->i) is not eliminated, notwithstanding the fact that the pointer has been dereferenced. If it is not null, bar is not called; otherwise, there is an undefined behavior, and bar is not called.

Or is it too an unimportant problem?

(It's interesting, after changing S_ptr p to struct S *p, the non-LTO build also fails with "undefined reference to `bar'".)
Comment 3 Richard Biener 2011-02-27 20:03:05 UTC
Hm, ok.  It's surely worth investigating.
Comment 4 Dmitry Gorbachev 2013-02-07 00:13:03 UTC
I can't reproduce it with GCC 4.6.4, 4.7.3, 4.8.0.