* [Bug c++/67056] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
@ 2015-07-29 14:26 ` ktkachov at gcc dot gnu.org
2015-07-29 14:53 ` trippels at gcc dot gnu.org
` (17 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2015-07-29 14:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
--- Comment #1 from ktkachov at gcc dot gnu.org ---
There are some tips and instructions at:
https://gcc.gnu.org/bugs/
A reduced, preprocessed testcase would be ideal.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/67056] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
2015-07-29 14:26 ` [Bug c++/67056] " ktkachov at gcc dot gnu.org
@ 2015-07-29 14:53 ` trippels at gcc dot gnu.org
2015-07-29 14:59 ` balder@yahoo-inc.com
` (16 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-07-29 14:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |trippels at gcc dot gnu.org
--- Comment #2 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
Also try to build your project with -fsanitize=undefined and see
if any issues pop up while running the unit tests.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/67056] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
2015-07-29 14:26 ` [Bug c++/67056] " ktkachov at gcc dot gnu.org
2015-07-29 14:53 ` trippels at gcc dot gnu.org
@ 2015-07-29 14:59 ` balder@yahoo-inc.com
2015-07-29 15:39 ` balder@yahoo-inc.com
` (15 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: balder@yahoo-inc.com @ 2015-07-29 14:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
--- Comment #3 from Henning Baldersheim <balder@yahoo-inc.com> ---
valgrind does not complain about anything undefined, but will try the sanitize
option too.
Will also try to isolate it as much as possible.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/67056] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (2 preceding siblings ...)
2015-07-29 14:59 ` balder@yahoo-inc.com
@ 2015-07-29 15:39 ` balder@yahoo-inc.com
2015-08-04 13:06 ` vegard@yahoo-inc.com
` (14 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: balder@yahoo-inc.com @ 2015-07-29 15:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
--- Comment #4 from Henning Baldersheim <balder@yahoo-inc.com> ---
Using the -fsanitize-undefined caused this error.
configretriever.cpp: info: running test suite 'configretriever.cpp'
/home/y/include/c++/5.2.0/bits/unique_ptr.h:76:2: runtime error: execution
reached a __builtin_unreachable() call
make: *** [test] Error 1
While it works fine when not inlining the constructor.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/67056] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (3 preceding siblings ...)
2015-07-29 15:39 ` balder@yahoo-inc.com
@ 2015-08-04 13:06 ` vegard@yahoo-inc.com
2015-08-04 13:09 ` vegard@yahoo-inc.com
` (13 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: vegard@yahoo-inc.com @ 2015-08-04 13:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
Vegard Sjonfjell <vegard@yahoo-inc.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vegard@yahoo-inc.com
--- Comment #5 from Vegard Sjonfjell <vegard@yahoo-inc.com> ---
Created attachment 36122
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36122&action=edit
Minimal failing example
We've tried to strip the code down to a minimal failing example. Compile with
-O3 -fPIC -std=c++11 (or std=c++14).
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/67056] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (4 preceding siblings ...)
2015-08-04 13:06 ` vegard@yahoo-inc.com
@ 2015-08-04 13:09 ` vegard@yahoo-inc.com
2015-08-04 14:43 ` trippels at gcc dot gnu.org
` (12 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: vegard@yahoo-inc.com @ 2015-08-04 13:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
--- Comment #6 from Vegard Sjonfjell <vegard@yahoo-inc.com> ---
Created attachment 36123
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36123&action=edit
Preprocessed file
Also adding the preprocessed file.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug c++/67056] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (5 preceding siblings ...)
2015-08-04 13:09 ` vegard@yahoo-inc.com
@ 2015-08-04 14:43 ` trippels at gcc dot gnu.org
2015-08-04 14:45 ` [Bug ipa/67056] [5/6 regression] " trippels at gcc dot gnu.org
` (11 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-08-04 14:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
--- Comment #7 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
Created attachment 36126
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36126&action=edit
Somewhat reduced testcase
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug ipa/67056] [5/6 regression] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (6 preceding siblings ...)
2015-08-04 14:43 ` trippels at gcc dot gnu.org
@ 2015-08-04 14:45 ` trippels at gcc dot gnu.org
2015-08-04 15:47 ` trippels at gcc dot gnu.org
` (10 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-08-04 14:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-08-04
CC| |hubicka at gcc dot gnu.org
Component|c++ |ipa
Summary|Wrong code generated |[5/6 regression] Wrong code
| |generated
Ever confirmed|0 |1
--- Comment #8 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
markus@x4 tmp % g++ -fsanitize=undefined -std=c++14 -O2 -fPIC mem.ii
markus@x4 tmp % ./a.out
mem.ii:72:5: runtime error: execution reached a __builtin_unreachable() call
markus@x4 tmp % g++ -fno-devirtualize -fsanitize=undefined -std=c++14 -O2
-fPIC mem.ii
markus@x4 tmp % ./a.out
markus@x4 tmp %
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug ipa/67056] [5/6 regression] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (7 preceding siblings ...)
2015-08-04 14:45 ` [Bug ipa/67056] [5/6 regression] " trippels at gcc dot gnu.org
@ 2015-08-04 15:47 ` trippels at gcc dot gnu.org
2015-08-05 7:30 ` balder@yahoo-inc.com
` (9 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-08-04 15:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
--- Comment #9 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
Started with r215902.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug ipa/67056] [5/6 regression] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (8 preceding siblings ...)
2015-08-04 15:47 ` trippels at gcc dot gnu.org
@ 2015-08-05 7:30 ` balder@yahoo-inc.com
2015-08-05 8:07 ` trippels at gcc dot gnu.org
` (8 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: balder@yahoo-inc.com @ 2015-08-05 7:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
--- Comment #10 from Henning Baldersheim <balder@yahoo-inc.com> ---
Wrong code generation on valid code does sound like a P2 to me.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug ipa/67056] [5/6 regression] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (9 preceding siblings ...)
2015-08-05 7:30 ` balder@yahoo-inc.com
@ 2015-08-05 8:07 ` trippels at gcc dot gnu.org
2015-08-05 10:02 ` trippels at gcc dot gnu.org
` (7 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-08-05 8:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
--- Comment #11 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
(In reply to Henning Baldersheim from comment #10)
> Wrong code generation on valid code does sound like a P2 to me.
The release manager sets the importance.
Another question is if the transition from "requests valid" to
"wrong code" is a regression at all.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug ipa/67056] [5/6 regression] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (10 preceding siblings ...)
2015-08-05 8:07 ` trippels at gcc dot gnu.org
@ 2015-08-05 10:02 ` trippels at gcc dot gnu.org
2015-10-12 8:13 ` hubicka at gcc dot gnu.org
` (6 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-08-05 10:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
--- Comment #12 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
(In reply to Markus Trippelsdorf from comment #11)
> Another question is if the transition from "requests valid" to
> "wrong code" is a regression at all.
Apart from the typo (s/requests/rejects) please ignore the comment
above, it was meant for a different PR.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug ipa/67056] [5/6 regression] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (11 preceding siblings ...)
2015-08-05 10:02 ` trippels at gcc dot gnu.org
@ 2015-10-12 8:13 ` hubicka at gcc dot gnu.org
2015-10-16 4:45 ` hubicka at gcc dot gnu.org
` (5 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: hubicka at gcc dot gnu.org @ 2015-10-12 8:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |hubicka at gcc dot gnu.org
--- Comment #13 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Will take a look.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug ipa/67056] [5/6 regression] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (12 preceding siblings ...)
2015-10-12 8:13 ` hubicka at gcc dot gnu.org
@ 2015-10-16 4:45 ` hubicka at gcc dot gnu.org
2015-10-16 4:46 ` hubicka at gcc dot gnu.org
` (4 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: hubicka at gcc dot gnu.org @ 2015-10-16 4:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
--- Comment #14 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
OK, the unreachable is introduced here:
- Creating a specialized node of bool staticBoolFunc(CompositeClass*)/414 for
all known contexts.
the new node is <built-in>/977.
known ctx 0 is Outer type (dynamic):struct EmptyClass offset -64
No devirtualization target in <built-in>/977
ipa-prop: Discovered a virtual call to a known target (<built-in>/977 -> void
__builtin_unreachable()/976), for stmt OBJ_TYPE_REF(_15;ptr_2(D)->1)
(ptr_2(D));
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/unique_ptr.h:76:2: note:
converting indirect call in <built-in> to direct call to void
__builtin_unreachable()
No devirtualization target in <built-in>/977
ipa-prop: Discovered a virtual call to a known target (<built-in>/977 -> void
__builtin_unreachable()/976), for stmt OBJ_TYPE_REF(_27;ptr_2(D)->1)
(ptr_2(D));
/aux/hubicka/trunk-install/include/c++/6.0.0/bits/unique_ptr.h:76:2: note:
converting indirect call in <built-in> to direct call to void
__builtin_unreachable()
So ipa-CP thinks that staticBoolFunc is called on EmptyClass instead of
CompositeClass:
Jump functions:
Jump functions of caller long unsigned int __builtin_object_size(const
void*, int)/967:
Jump functions of caller void operator delete(void*, long unsigned int)/964:
Jump functions of caller void* operator new(std::size_t)/963:
Jump functions of caller int main(int, char**)/415:
callsite int main(int, char**)/415 -> void operator delete(void*, long
unsigned int)/964 :
callsite int main(int, char**)/415 -> bool
staticBoolFunc(CompositeClass*)/414 :
param 0: UNKNOWN
Context: Outer type (dynamic):struct EmptyClass offset -64
Unknown alignment
callsite int main(int, char**)/415 -> EmptyClass::EmptyClass()/404 :
param 0: UNKNOWN
Context: Outer type (dynamic): (or a derived type) (maybe in
construction) offset 64 Speculative outer type:struct CompositeClass (or a
derived type) at offset 64
Unknown alignment
This is indeed wrong. Jump function analysis seems to confuse constructors:
Modification phase of node int main(int, char**)/402
int main(int, char**) (int D.39529, char * * D.39530)
{
void * _3;
struct EmptyClass * _7;
<bb 2>:
_3 = operator new (16);
MEM[(struct &)_3] ={v} {CLOBBER};
MEM[(struct CompositeClass *)_3]._vptr.CompositeClass = &MEM[(void
*)&_ZTV14CompositeClass + 16B];
_7 = &MEM[(struct CompositeClass *)_3].object;
EmptyClass::EmptyClass (_7);
<bb 3>:
staticBoolFunc (_3);
return 0;
<L1>:
operator delete (_3, 16);
resx 1
EmptyClass ctor is called, but it should not type the object.
Determining dynamic type for call: staticBoolFunc (_3);
Starting walk at: staticBoolFunc (_3);
instance pointer: _3 Outer instance pointer: _3 offset: 0 (bits) vtbl
reference:
Checking constructor call: EmptyClass::EmptyClass (_7);
Recording type: struct EmptyClass at offset -64
Determined dynamic type.
This is quite a nonsense, because EmptyClass is not even. So there are two
bugs.
First is that we determine useless outer type. This should be just missed
optimization. But we also manage to consider to miss the case in placement_new
checking where we are completely off the structure....
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug ipa/67056] [5/6 regression] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (13 preceding siblings ...)
2015-10-16 4:45 ` hubicka at gcc dot gnu.org
@ 2015-10-16 4:46 ` hubicka at gcc dot gnu.org
2015-10-16 6:25 ` hubicka at gcc dot gnu.org
` (3 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: hubicka at gcc dot gnu.org @ 2015-10-16 4:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
--- Comment #15 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Created attachment 36520
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36520&action=edit
Fix I am teching.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug ipa/67056] [5/6 regression] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (14 preceding siblings ...)
2015-10-16 4:46 ` hubicka at gcc dot gnu.org
@ 2015-10-16 6:25 ` hubicka at gcc dot gnu.org
2015-10-16 8:28 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: hubicka at gcc dot gnu.org @ 2015-10-16 6:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |doko at gcc dot gnu.org
--- Comment #16 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
*** Bug 66738 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug ipa/67056] [5/6 regression] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (15 preceding siblings ...)
2015-10-16 6:25 ` hubicka at gcc dot gnu.org
@ 2015-10-16 8:28 ` rguenth at gcc dot gnu.org
2015-10-21 21:14 ` hubicka at gcc dot gnu.org
2015-10-22 3:19 ` [Bug ipa/67056] [5 " hubicka at gcc dot gnu.org
18 siblings, 0 replies; 20+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-16 8:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |5.3
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug ipa/67056] [5/6 regression] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (16 preceding siblings ...)
2015-10-16 8:28 ` rguenth at gcc dot gnu.org
@ 2015-10-21 21:14 ` hubicka at gcc dot gnu.org
2015-10-22 3:19 ` [Bug ipa/67056] [5 " hubicka at gcc dot gnu.org
18 siblings, 0 replies; 20+ messages in thread
From: hubicka at gcc dot gnu.org @ 2015-10-21 21:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
--- Comment #17 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Author: hubicka
Date: Wed Oct 21 21:14:06 2015
New Revision: 229148
URL: https://gcc.gnu.org/viewcvs?rev=229148&root=gcc&view=rev
Log:
PR ipa/67056
* ipa-polymorphic-call.c (possible_placement_new): If cur_offset
is negative we don't know the type.
(check_stmt_for_type_change): Skip constructors of non-polymorphic
types as those won't help devirutalization.
* g++.dg/ipa/pr67056.C: New testcase.
Added:
trunk/gcc/testsuite/g++.dg/ipa/pr67056.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/ipa-polymorphic-call.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Bug ipa/67056] [5 regression] Wrong code generated
2015-07-29 14:24 [Bug c++/67056] New: Wrong code generated balder@yahoo-inc.com
` (17 preceding siblings ...)
2015-10-21 21:14 ` hubicka at gcc dot gnu.org
@ 2015-10-22 3:19 ` hubicka at gcc dot gnu.org
18 siblings, 0 replies; 20+ messages in thread
From: hubicka at gcc dot gnu.org @ 2015-10-22 3:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67056
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |UNCONFIRMED
Summary|[5/6 regression] Wrong code |[5 regression] Wrong code
|generated |generated
Ever confirmed|1 |0
--- Comment #18 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Fixed on trunk so far; fix is backportable.
^ permalink raw reply [flat|nested] 20+ messages in thread