[Bug c/91031] wrong code generated when using compound literal

2020-05-06 Thread makhaloff at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91031

--- Comment #5 from Alexey Makhalov  ---
(In reply to Andrew Pinski from comment #1)
> In previous versions of gcc, the compound literal was put in the function
> level scope rather than in the current scope. Which is why it worked
> previously.  But the code was undefined.  This was added to the changes page
> too.

Hi Andrew, thanks for the update.

There is an inconsistency which is really worried me.

1) The behavior of GCC is different (from user point of view). -O0 allocates
anonymous variable per function, but -01 and higher allocate it per scope?

2) this sample will allocate anonymous (char *)"test" per function scope with
any optimization

#include 

int testme(char *j) {
if (!j)
j = (char *)"test";

return strlen(j) == 4;
}

int main(void) {
return testme(0) == 0;
}
--
3) Why GCC does not provide any warning/errors in that case?

4) Even if anonymous variable put only in current scope (with optimization), I
still see space for it was allocated in function frame.
I can give you bigger example where array of pointers was allocated on stack in
prologue, but was not initialized.

Can you point to the commit which introduced this change, please?

PS: went to read C standard for anonymous variables.

[Bug c/94979] New: gcc-9 generates incorrect code causing segfault

2020-05-06 Thread makhaloff at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94979

Bug ID: 94979
   Summary: gcc-9 generates incorrect code causing segfault
   Product: gcc
   Version: 9.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: makhaloff at gmail dot com
  Target Milestone: ---

I found this issue while compiling systemd-239 with gcc-9.3.0

The problem is in local data initialization on the stack such as array of
pointers to global data.

-O0 is fine, but -01,02,03 eliminates such data causing app to segfault. 

Confirmed gcc-9 branch (up to commit 25c60fcadc397c42a0ec778e5b123f2c94d3)
still has this bug.


Test program is attached below.
Additional info and steps to reproduce:

~/gcc$ ./host-x86_64-pc-linux-gnu/gcc/xgcc -v
Using built-in specs.
COLLECT_GCC=./host-x86_64-pc-linux-gnu/gcc/xgcc
Target: x86_64-pc-linux-gnu
Configured with: ./configure --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c
--disable-multilib --disable-bootstrap --disable-libstdcxx-pch
--enable-linker-build-id --enable-plugin --with-system-zlib
Thread model: posix
gcc version 9.3.1 20200507 (GCC)
~/gcc$ ./host-x86_64-pc-linux-gnu/gcc/xgcc -B./host-x86_64-pc-linux-gnu/gcc/
test.c
~/gcc$ ./a.out
~/gcc$ echo $?
0
~/gcc$ ./host-x86_64-pc-linux-gnu/gcc/xgcc -B./host-x86_64-pc-linux-gnu/gcc/
-O1 test.c
~/gcc$ ./a.out
Segmentation fault (core dumped)


= test.c ==

#include 

int chararray(char **j) {
if (!j)
j = (char *[]){"a", "test"};

return (strlen(j[0]) == 1) & (strlen(j[1]) == 4);
}

int main(void) {
return chararray(0) == 0;
}

===

[Bug rtl-optimization/60307] define_cond_exec with cc0 comparison generates wrong code, missing insn that sets cc0

2014-02-22 Thread makhaloff at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60307

--- Comment #2 from Alexey Makhalov  ---
It's new processor architecture. It doesn't present in GCC sources.

I've took a look through all targets and figured out that there are no targets
who supports cc0 and conditional execution together. So it looks like never
used/tested field.

Also I've met a problem with conditional move and cc0. I get ICE at reload
pass. I don't know what happens. I'm working on it now.


[Bug rtl-optimization/60307] New: define_cond_exec with cc0 comparison generates wrong code, missing insn that sets cc0

2014-02-21 Thread makhaloff at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60307

Bug ID: 60307
   Summary: define_cond_exec with cc0 comparison generates wrong
code, missing insn that sets cc0
   Product: gcc
   Version: 4.8.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: makhaloff at gmail dot com

Created attachment 32193
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32193&action=edit
Support conditional execution with cc0

My target has:
#define HAVE_cc0 1
#define HAVE_conditional_execution 1
(from generated file insn-config.h)

ce3 (ifcvt.c) pass converts conditional jump into conditional execution well.
But rtl_merge_blocks (cfgrtl.c) when removes conditional jump, it also removes
insn that sets cc0, without analyze if it might be used in following (just
inserted) cond_exec insn.
As result, we have cond_exec insn without cc0 setter.

I've fixed that moment. It works for me. All gcc tests are passed.
Patch is attached.

Alexey.


[Bug rtl-optimization/60089] New: Complex arithmetic instructions

2014-02-05 Thread makhaloff at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60089

Bug ID: 60089
   Summary: Complex arithmetic instructions
   Product: gcc
   Version: 4.8.2
Status: UNCONFIRMED
  Severity: minor
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: makhaloff at gmail dot com

Hello.

I'm porting gcc on some architecture which has complex addition, subtraction
and multiplication instructions.

I was trying to define addchi3, subchi3 but it doesn't work.
I've figured out that complex operations are lowered at the tree-level.

Is there any way to support these instructions?

Thanks.


[Bug middle-end/59553] New: emit_library_call_value_1 generates usage of virtual_outgoint_args_rtx when virtuals_instantiated is 1

2013-12-18 Thread makhaloff at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59553

Bug ID: 59553
   Summary: emit_library_call_value_1 generates usage of
virtual_outgoint_args_rtx when virtuals_instantiated
is 1
   Product: gcc
   Version: 4.8.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: makhaloff at gmail dot com

Created attachment 31476
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31476&action=edit
patch to fix that problem

I'm porting gcc on some target.
I have following macroses:
#define ACCUMULATE_OUTGOING_ARGS 0
#define PUSH_ARGS 1
#define PUSH_ARGS_REVERSED 0

As you can see it's rarely case.

I got following ICE:
webizer.c: In function 'configure2':
webizer.c:30:1: internal compiler error: in replace_pseudos_in, at
reload1.c:576
 }
 ^
0x8386eea replace_pseudos_in
../../gcc-4.8.2/gcc/reload1.c:575
0x8386eae replace_pseudos_in
../../gcc-4.8.2/gcc/reload1.c:592
0x8386eae replace_pseudos_in
../../gcc-4.8.2/gcc/reload1.c:592
0x8386eae replace_pseudos_in
../../gcc-4.8.2/gcc/reload1.c:592
0x839160f reload(rtx_def*, int)
../../gcc-4.8.2/gcc/reload1.c:1185
0x82cb8eb do_reload
../../gcc-4.8.2/gcc/ira.c:4679
0x82cb8eb rest_of_handle_reload
../../gcc-4.8.2/gcc/ira.c:4779


replace_pseudos_in was trying to replace virtual-outgoing-args in that
instruction:

(call_insn/u 121 601 124 4 (parallel [
(set (reg:SI 0 r0)
(call (mem:SI (symbol_ref:SI ("__lshrsi3") [flags 0x41]) [0 S4
A32])
(const_int 8 [0x8])))
]) 38 {call_value_insn_sym}
 (expr_list:REG_EH_REGION (const_int -2147483648 [0x8000])
(nil))
(expr_list:REG_DEP_TRUE (use (mem:SI (plus:SI (reg/f:SI 16
virtual-outgoing-args)
(scratch:SI)) [0 S4 A32]))
(expr_list:REG_DEP_TRUE (use (mem:SI (plus:SI (reg/f:SI 16
virtual-outgoing-args)
(scratch:SI)) [0 S4 A32]))
(nil

I found a place where gcc emits this call and expr list:
calls.c:4053 (emit_library_call_value_1)
At that moment virtuals_instantiated was equal 1.
So that is an error, because forbidden to use virtual regs when
virtuals_instantiated is nonzero.

I decide to make changes similar to calls.c:3915 (to use SP + OFFSET)
It works for me.

--- calls.c2013-12-19 00:16:59.857462118 -0800
+++ calls.c2013-12-19 00:39:03.780723916 -0800
@@ -4050,8 +4050,14 @@
auto-increment causes confusion.  So we merely indicate
that we access something with a known mode somewhere on
the stack.  */
-use = gen_rtx_PLUS (Pmode, virtual_outgoing_args_rtx,
-gen_rtx_SCRATCH (Pmode));
+if (virtuals_instantiated)
+  use = gen_rtx_PLUS (Pmode, 
+  plus_constant (Pmode, stack_pointer_rtx,
+   STACK_POINTER_OFFSET),
+  gen_rtx_SCRATCH (Pmode));
+else
+  use = gen_rtx_PLUS (Pmode, virtual_outgoing_args_rtx,
+  gen_rtx_SCRATCH (Pmode));
   use = gen_rtx_MEM (argvec[argnum].mode, use);
   use = gen_rtx_USE (VOIDmode, use);
   call_fusage = gen_rtx_EXPR_LIST (VOIDmode, use, call_fusage);


Thanks.
Alexey


[Bug middle-end/59272] New: Incorrect name of TLS_MODEL_GLOBAL_DYNAMIC

2013-11-23 Thread makhaloff at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59272

Bug ID: 59272
   Summary: Incorrect name of TLS_MODEL_GLOBAL_DYNAMIC
   Product: gcc
   Version: 4.8.1
Status: UNCONFIRMED
  Severity: minor
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: makhaloff at gmail dot com

gcc/coretypes.h contains TLS_MODEL_GLOBAL_DYNAMIC item in tls_model enum.

TLS GD model is called "General Dynamic" in a lot of documentation.
Some of them are listed below:
http://www.akkadia.org/drepper/tls.pdf
http://docs.oracle.com/cd/E23824_01/html/819-0690/chapter8-20.html

I think the better name is TLS_MODEL_GENERAL_DYNAMIC


[Bug rtl-optimization/57940] New: [PATCH] Rerun df_analyze after delete_unmarked_insns during DCE

2013-07-20 Thread makhaloff at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57940

Bug ID: 57940
   Summary: [PATCH] Rerun df_analyze after delete_unmarked_insns
during DCE
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: makhaloff at gmail dot com

Hello!

If delete_unmarked_insns deletes some insn, DF state might be
out of date, and, regs_ever_live might contain unused registers till the end.
Fixed by forcing regs_ever_live update and rerunning df_analyze () at
fini_dce().
I found this bug on my target (not included into main sources). But I can send
everything you need to reproduce this bug.
Using gcc-4.8.1 

2013-07-20  Alexey Makhalov  

* dce.c (fini_dce): Call df_analyze again just in case
delete_unmarked_insns removed anything.

--- dce.c   (revision 361)
+++ dce.c   (working copy)
@@ -745,6 +745,12 @@
   bitmap_obstack_release (&dce_blocks_bitmap_obstack);
   bitmap_obstack_release (&dce_tmp_bitmap_obstack);
 }
+
+  if (!df_in_progress)
+{
+  df_compute_regs_ever_live (true);
+  df_analyze ();
+}
 }