libgomp testsuite fails with a segfault. It segfaults in gomp_resolve_num_threads(), accessing the second TLS value.
The first access: .LBB28: .file 2 "../../../src/libgomp/libgomp.h" .loc 2 380 0 bcl 20,31,$+8 .long _GLOBAL_OFFSET_TABLE_-$ mflr 9 lwz 0,0(9) add 9,9,0 lwz 9,gomp_tls_d...@got@tprel(9) add 9,9,gomp_tls_d...@tls lwz 9,40(9) The second: .LBE27: .loc 1 47 0 cmpwi 7,3,1 beq- 7,.L37 .LVL32: .loc 1 49 0 bcl 20,31,$+8 .long _GLOBAL_OFFSET_TABLE_-$ mflr 9 add 9,9,0 lwz 9,gomp_tls_d...@got@tprel(9) add 9,9,gomp_tls_d...@tls lwz 0,28(9) After mflr, the lwz is missing. r0 has the offset from last lr which is wrong here. The RTL in tc.c.185r.cprop_hardreg has the lwz included, the next pass tc.c.186r.dce does not anymore. lwz gets not killed if I used -mcpu=power or -mcpu=e300c3. I used -mcpu=8540 which is default for powerpc-linux-gnuspe. -O1 was used in the test case. The complete cmd line: /build/bigeasy/gcc-4.4-4.4.4/build/./gcc/xgcc \ -B/build/bigeasy/gcc-4.4-4.4.4/build/./gcc/ \ -B/usr/powerpc-linux-gnuspe/bin/ \ -B/usr/powerpc-linux-gnuspe/lib/ \ -isystem \ /usr/powerpc-linux-gnuspe/include \ -isystem \ /usr/powerpc-linux-gnuspe/sys-include \ -Werror \ -pthread \ -ftls-model=initial-exec \ -O2 \ -pthread \ -fPIC \ -DPIC \ tc.c \ -o \ tc.S \ -S \ -mcpu=8540 \ -O1 \ -fdump-rtl-all \ -c \ A side note: the complete file (parallel.c from libgomp) was compiled with -O2 and the lwz was killed between parallel.c.174r.postreload and parallel.c.176r.split2. -- Summary: Wrong code while generating TLS offsets Product: gcc Version: 4.4.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gcc at breakpoint dot cc GCC build triplet: powerpc-linux-gnuspe GCC host triplet: powerpc-linux-gnuspe GCC target triplet: powerpc-linux-gnuspe http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44169