[Bug tree-optimization/59622] [4.9 Regression] internal compiler error: verify_gimple failed

2014-01-09 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59622

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #17 from Jakub Jelinek jakub at gcc dot gnu.org ---
Fixed.


[Bug tree-optimization/59622] [4.9 Regression] internal compiler error: verify_gimple failed

2014-01-09 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59622

--- Comment #18 from Jakub Jelinek jakub at gcc dot gnu.org ---
Author: jakub
Date: Thu Jan  9 20:09:33 2014
New Revision: 206492

URL: http://gcc.gnu.org/viewcvs?rev=206492root=gccview=rev
Log:
PR tree-optimization/59622
* gimple-fold.c (gimple_fold_call): Fix a typo in message.  For
__builtin_unreachable replace the OBJ_TYPE_REF call with a call to
__builtin_unreachable and add if needed a setter of the lhs SSA_NAME.
Don't devirtualize for inplace at all.  For targets.length () == 1,
if the call is noreturn and cfun isn't in SSA form yet, clear lhs.

* g++.dg/opt/pr59622-2.C: New test.
* g++.dg/opt/pr59622-3.C: New test.
* g++.dg/opt/pr59622-4.C: New test.
* g++.dg/opt/pr59622-5.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/opt/pr59622-2.C
trunk/gcc/testsuite/g++.dg/opt/pr59622-3.C
trunk/gcc/testsuite/g++.dg/opt/pr59622-4.C
trunk/gcc/testsuite/g++.dg/opt/pr59622-5.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/gimple-fold.c
trunk/gcc/testsuite/ChangeLog


[Bug tree-optimization/59622] [4.9 Regression] internal compiler error: verify_gimple failed

2014-01-02 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59622

--- Comment #15 from Jakub Jelinek jakub at gcc dot gnu.org ---
Created attachment 31561
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=31561action=edit
gcc49-pr59622-2.patch

So, do we want something like this?  For incompatible return type or argument
types punt, unless it is the __builtin_unreachable/__cxa_pure_virtual case
which can be handled the same, and similarly punt for inplace if the call flags
would change?


[Bug tree-optimization/59622] [4.9 Regression] internal compiler error: verify_gimple failed

2014-01-02 Thread hubicka at ucw dot cz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59622

--- Comment #16 from Jan Hubicka hubicka at ucw dot cz ---
 So, do we want something like this?  For incompatible return type or argument
 types punt, unless it is the __builtin_unreachable/__cxa_pure_virtual case
 which can be handled the same, and similarly punt for inplace if the call 
 flags
 would change?

Punting on methods with wrong return/parameter types seems resonable. We
probably
could/should warn here, since it almost definitely means ODR volation.
I would definitely try some code with warning on - type compatibility is
splipperly,
but testing in sense of useless_ssa_conversion should pass for all valid
programs.

Handling unreacahble/cxa_pure_virtual separately seems sane, too.

I am not too happy about giving up with inplace folding given that we forget to
fold statements later, but that is probably for indepenedent PR/patch.

So this approach is fine for me.  Thanks for looking into this!
Honza


[Bug tree-optimization/59622] [4.9 Regression] internal compiler error: verify_gimple failed

2013-12-31 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59622

--- Comment #13 from Jakub Jelinek jakub at gcc dot gnu.org ---
Author: jakub
Date: Tue Dec 31 11:57:39 2013
New Revision: 206264

URL: http://gcc.gnu.org/viewcvs?rev=206264root=gccview=rev
Log:
PR tree-optimization/59622
* gimple-fold.c (gimple_fold_call): Don't replace OBJ_TYPE_REF
call fndecl with 0 possible targets with BUILT_IN_UNREACHABLE,
instead only for !inplace add a __builtin_unreachable () call
before the call.

* g++.dg/opt/pr59622.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/opt/pr59622.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/gimple-fold.c
trunk/gcc/testsuite/ChangeLog


[Bug tree-optimization/59622] [4.9 Regression] internal compiler error: verify_gimple failed

2013-12-31 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59622

--- Comment #14 from Jakub Jelinek jakub at gcc dot gnu.org ---
Ah, ok, the #c12 testcase is indeed a different case, targets doesn't have
length 0 in that case, but length 1, but targets[0]-decl is __cxa_pure_virtual
function, which is similar to __builtin_unreachable in that it takes no
arguments, has void return value and is noreturn.
So, supposedly for the length 1 case gimple_fold_call should compare if the
return type is compatible with the lhs type if it has lhs, for !inplace just
punt (similarly for the case (always?) when the number of arguments is bigger
than the called one), for inplace I guess we can replace it by a different call
but would need to do for the lhs what I mentioned (if it has lhs and the lhs
has gimple_reg_type, set it to zero after the noreturn call with void type).
For other incompatibilities in the return value or arguments, perhaps we should
just not try to fold it at all.


[Bug tree-optimization/59622] [4.9 Regression] internal compiler error: verify_gimple failed

2013-12-30 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59622

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek jakub at gcc dot gnu.org ---
Created attachment 31539
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=31539action=edit
gcc49-pr59622.patch

Untested fix.  I think just adding __builtin_unreachable () call before the
call and not folding the call at all is best, no need to attempt to handle the
lhs etc., DCE will do it's job later on.


[Bug tree-optimization/59622] [4.9 Regression] internal compiler error: verify_gimple failed

2013-12-30 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59622

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

 CC||jason at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek jakub at gcc dot gnu.org ---
BTW, I wonder if we shouldn't issue a warning on this testcase, if the vtable
(and virtual method) are in anonymous namespace and aren't defined in the
current CU, they can't be defined anywhere else and thus it is a user error not
to define them (or the class shouldn't be used where the vtable is needed).
At -O0 on the testcase we end up with _ZTVN12_GLOBAL__N_11AE undefined symbol
(that, again, can't be defined anywhere else), so that is at least link time
error, but at -O2 we don't get that.


[Bug tree-optimization/59622] [4.9 Regression] internal compiler error: verify_gimple failed

2013-12-30 Thread hubicka at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59622

Jan Hubicka hubicka at gcc dot gnu.org changed:

   What|Removed |Added

 CC||hubicka at gcc dot gnu.org

--- Comment #8 from Jan Hubicka hubicka at gcc dot gnu.org ---
About the warning, I think it would lead to false positives.  We can specialize
function for particular type and the type may not define a virtual method.
User may have earlier correctly tested the dynamic type of the objects making
the code path dead.


[Bug tree-optimization/59622] [4.9 Regression] internal compiler error: verify_gimple failed

2013-12-30 Thread hubicka at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59622

--- Comment #9 from Jan Hubicka hubicka at gcc dot gnu.org ---
My comment was about warning at a time we fold to unreachable. Higher level
warning a-la clang is of course good idea.


[Bug tree-optimization/59622] [4.9 Regression] internal compiler error: verify_gimple failed

2013-12-30 Thread nheghathivhistha at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59622

--- Comment #10 from David Kredba nheghathivhistha at gmail dot com ---
Hello Jakub,
I tried your patch.

/var/tmp/portage/sys-devel/llvm-3.3-r2/work/llvm-3.3.src/lib/Transforms/Scalar/SimplifyLibCalls.cpp:
In member function ‘llvm::Value*
{anonymous}::LibCallOptimization::OptimizeCall(llvm::CallInst*, const
llvm::DataLayout*, const llvm::TargetLibraryInfo*, llvm::IRBuilder)’:
/var/tmp/portage/sys-devel/llvm-3.3-r2/work/llvm-3.3.src/lib/Transforms/Scalar/SimplifyLibCalls.cpp:63:10:
error: LHS in noreturn call
   Value *OptimizeCall(CallInst *CI, const DataLayout *TD,
  ^
D.109494 = __cxa_pure_virtual (this, D.109498, CI, B);
/var/tmp/portage/sys-devel/llvm-3.3-r2/work/llvm-3.3.src/lib/Transforms/Scalar/SimplifyLibCalls.cpp:63:10:
internal compiler error: verify_gimple failed

Do you need a new reduced testcase?

[Bug tree-optimization/59622] [4.9 Regression] internal compiler error: verify_gimple failed

2013-12-30 Thread nheghathivhistha at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59622

--- Comment #11 from David Kredba nheghathivhistha at gmail dot com ---
Without -m32 it not ICEs after patch applied.


[Bug tree-optimization/59622] [4.9 Regression] internal compiler error: verify_gimple failed

2013-12-30 Thread nheghathivhistha at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59622

--- Comment #12 from David Kredba nheghathivhistha at gmail dot com ---
Created attachment 31546
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=31546action=edit
After patch ICE generating reduced preprocessed source file