Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal compiler error on optimization #13

Closed
fxcoudert opened this issue Aug 31, 2020 · 2 comments
Closed

Internal compiler error on optimization #13

fxcoudert opened this issue Aug 31, 2020 · 2 comments

Comments

@fxcoudert
Copy link
Contributor

Reduced from gcc.dg/autopar/reduc-8.c:

$ cat reduc-8.c      
void testmax (const char *c)
{
  char accum = 0;
  int i;

  for (i = 0; i < 3200; i++) {
    accum += c[i];
  }
}

int __attribute__((optimize ("-ftree-parallelize-loops=0")))
main (void)
{ 
  static char C[3200] = { 0xff };
  testmax (C);
}
$ ./bin/gcc reduc-8.c
$ ./bin/gcc reduc-8.c -O
reduc-8.c:16:1: internal compiler error: Segmentation fault: 11
   16 | }
      | ^
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.

The backtrace for the ICE is not very helpful, I'm afraid:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000000000000
    frame #1: 0x00000001011bb6a0 cc1`output_object_blocks() at varasm.c:7682:35
    frame #2: 0x0000000100de7750 cc1`::compile_file() at toplev.c:515:28
    frame #3: 0x000000010139ce2c cc1`toplev::main(int, std::__va_list*) at toplev.c:2314:24
    frame #4: 0x000000010139cb08 cc1`toplev::main(this=0x000000016fdff8f8, argc=<unavailable>, argv=<unavailable>)
    frame #5: 0x000000010139e77c cc1`main(argc=18, argv=0x000000016fdff938) at main.c:39:22
    frame #6: 0x00000001d29e8a04 libdyld.dylib`start + 4
@iains
Copy link
Owner

iains commented Sep 2, 2020

OK, so this is something to do with section anchors. Unfortunately, section anchors don't play nicely with the ld64/Mach-O atom model:

  • ld64 thinks it is free to split things on any linker-visible symbol, but section anchors work on the basis of a block of stuff that's stuck together with a starting symbol and then a series of smaller offsets ... splitting that up will crash.

  • traditionally, 0-sized objects have been allowed in ELF semantics, this messes with the atom model too.

I did make section anchors work for PowerPC Darwin, a long time ago - but it was a bit messy and I'm not sure how much it was used. So ..... my initial inclination is to look for a way to switch this off - or to make sure it's limited to cases that won't upset ld64.

iains added a commit that referenced this issue Sep 2, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
@iains
Copy link
Owner

iains commented Sep 2, 2020

"fixed" (i.e. disabled) by the commit mentioned.

@iains iains closed this as completed Sep 2, 2020
iains added a commit that referenced this issue Sep 5, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Sep 7, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Sep 12, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Sep 25, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Sep 29, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Oct 4, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Oct 12, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Oct 17, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Oct 25, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Nov 1, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains pushed a commit that referenced this issue Nov 7, 2020
Enable thumb1_gen_const_int to generate RTL or asm depending on the
context, so that we avoid duplicating code to handle constants in
Thumb-1 with -mpure-code.

Use a template so that the algorithm is effectively shared, and
rely on two classes to handle the actual emission as RTL or asm.

The generated sequence is improved to handle right-shiftable and small
values with less instructions. We now generate:

128:
        movs    r0, r0, #128
264:
        movs    r3, #33
        lsls    r3, #3
510:
        movs    r3, #255
        lsls    r3, #1
512:
        movs    r3, #1
        lsls    r3, #9
764:
        movs    r3, #191
        lsls    r3, #2
65536:
        movs    r3, #1
        lsls    r3, #16
0x123456:
        movs    r3, #18 ;0x12
        lsls    r3, #8
        adds    r3, #52 ;0x34
        lsls    r3, #8
        adds    r3, #86 ;0x56
0x1123456:
        movs    r3, #137 ;0x89
        lsls    r3, #8
        adds    r3, #26 ;0x1a
        lsls    r3, #8
        adds    r3, #43 ;0x2b
        lsls    r3, #1
0x1000010:
        movs    r3, #16
        lsls    r3, #16
        adds    r3, #1
        lsls    r3, #4
0x1000011:
        movs    r3, #1
        lsls    r3, #24
        adds    r3, #17
-8192:
	movs	r3, #1
	lsls	r3, #13
	rsbs	r3, #0

The patch adds a testcase which does not fully exercise
thumb1_gen_const_int, as other existing patterns already catch small
constants.  These parts of thumb1_gen_const_int are used by
arm_thumb1_mi_thunk.

2020-11-02  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/
	* config/arm/arm.c (thumb1_const_rtl, thumb1_const_print): New
	classes.
	(thumb1_gen_const_int): Rename to ...
	(thumb1_gen_const_int_1): ... New helper function. Add capability
	to emit either RTL or asm, improve generated code.
	(thumb1_gen_const_int_rtl): New function.
	* config/arm/arm-protos.h (thumb1_gen_const_int): Rename to
	thumb1_gen_const_int_rtl.
	* config/arm/thumb1.md: Call thumb1_gen_const_int_rtl instead
	of thumb1_gen_const_int.

	gcc/testsuite/
	* gcc.target/arm/pure-code/no-literal-pool-m0.c: New.
iains added a commit that referenced this issue Nov 7, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Nov 15, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Nov 22, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Nov 29, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Dec 6, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Dec 6, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Dec 19, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Dec 20, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Dec 26, 2020
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Jan 4, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Jan 11, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Jan 19, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Jan 24, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
omus pushed a commit to omus/gcc-darwin-arm64 that referenced this issue Jan 27, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue iains#13.
omus pushed a commit to omus/gcc-darwin-arm64 that referenced this issue Jan 27, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue iains#13.
iains added a commit that referenced this issue Sep 6, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Sep 26, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
Alphadelta14 pushed a commit to Alphadelta14/gcc-darwin-arm64 that referenced this issue Oct 18, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue iains#13.
iains added a commit that referenced this issue Oct 28, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Nov 6, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Nov 7, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Nov 13, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Nov 14, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Nov 21, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Nov 28, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Dec 7, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Dec 12, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Dec 18, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Dec 25, 2021
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Jan 2, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Jan 8, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Jan 15, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Jan 15, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Jan 22, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Jan 29, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Feb 6, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Feb 12, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Feb 19, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Feb 26, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Mar 5, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Mar 12, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Mar 19, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Mar 26, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Apr 2, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
iains added a commit that referenced this issue Apr 28, 2022
Section anchors are tricky with the ld64 atom model.  It is possible
to make them work in a sub-set of circumstances.

TODO: determine those cases and apply fixes to deal with them.

This fixes issue #13.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants