public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/50691] New: Incorrect argument evaluation in call with __thread argument
@ 2011-10-10 19:33 danglin at gcc dot gnu.org
2011-10-10 19:35 ` [Bug middle-end/50691] " danglin at gcc dot gnu.org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: danglin at gcc dot gnu.org @ 2011-10-10 19:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50691
Bug #: 50691
Summary: Incorrect argument evaluation in call with __thread
argument
Classification: Unclassified
Product: gcc
Version: 4.4.6
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: danglin@gcc.gnu.org
Host: hppa-unknown-linux-gnu
Target: hppa-unknown-linux-gnu
Build: hppa-unknown-linux-gnu
This was found debugging the FAIL of the reuse test in mpfr-3.1.0.
We have in mpfr_log2:
extern __thread mpfr_cache_t __gmpfr_cache_const_log2;
mpfr_t t, tt;
mpfr_cache(t, __gmpfr_cache_const_log2, MPFR_RNDD);
The generated assembly code is:
(gdb) disass $pc-64,$pc+32
Dump of assembler code from 0x403154d8 to 0x40315538:
0x403154d8 <mpfr_log2+452>: copy r4,r19
0x403154dc <mpfr_log2+456>: ldil L%-80000000,r11
0x403154e0 <mpfr_log2+460>: cmpiclr,<> 0,r7,r0
0x403154e4 <mpfr_log2+464>: addi 1,r13,r13
0x403154e8 <mpfr_log2+468>: ldi 20,r14
0x403154ec <mpfr_log2+472>: addil L%0,r19,r1
0x403154f0 <mpfr_log2+476>: ldo 7b4(r1),r12
0x403154f4 <mpfr_log2+480>: ldo 4(r11),r11
0x403154f8 <mpfr_log2+484>: copy r12,r26
0x403154fc <mpfr_log2+488>: b,l 0x403090e8,rp
0x40315500 <mpfr_log2+492>: copy r19,r4
0x40315504 <mpfr_log2+496>: copy r4,r19
0x40315508 <mpfr_log2+500>: copy ret0,r25
0x4031550c <mpfr_log2+504>: copy r19,r4
0x40315510 <mpfr_log2+508>: b,l 0x40309248,rp
0x40315514 <mpfr_log2+512>: ldi 3,r24
=> 0x40315518 <mpfr_log2+516>: copy r4,r19
The call at 0x40315510 is the call to mpfr_cache. The preceding
call at 0x403154fc is to __tls_get_addr. The argument setup for
it has clobbered the argument setup of the first argument to the
call to mpfr_cache.
We have in .expand:
;; mpfr_cache (&t, &__gmpfr_cache_const_log2, 3);
(insn 210 209 211 ../../src/log2.c:118 (set (reg:SI 26 %r26)
(reg/f:SI 90 virtual-stack-vars)) -1 (nil))
(insn 211 210 212 ../../src/log2.c:118 (parallel [
(set (reg:SI 181)
(unspec:SI [
(symbol_ref:SI ("__gmpfr_cache_const_log2") [flags 0x50]
<var_decl 0x402b2630 __gmpfr_cache_const_log2>)
] 10))
(clobber (reg:SI 1 %r1))
(use (reg:SI 19 %r19))
]) -1 (nil))
(insn 212 211 213 ../../src/log2.c:118 (set (reg:SI 26 %r26)
(reg:SI 181)) -1 (nil))
(call_insn/u 213 212 214 ../../src/log2.c:118 (parallel [
(set (reg:SI 4 %r4)
(reg:SI 19 %r19))
(set (reg:SI 28 %r28)
(call (mem:SI (symbol_ref/v:SI ("@__tls_get_addr") [flags 0x41])
[0 S4 A32])
(const_int 64 [0x40])))
(clobber (reg:SI 1 %r1))
(clobber (reg:SI 2 %r2))
(use (reg:SI 4 %r4))
(use (reg:SI 19 %r19))
(use (const_int 0 [0x0]))
]) -1 (expr_list:REG_EH_REGION (const_int 0 [0x0])
(nil))
(expr_list:REG_DEP_TRUE (use (reg:SI 26 %r26))
(nil)))
(insn 214 213 215 ../../src/log2.c:118 (set (reg:SI 182)
(reg:SI 28 %r28)) -1 (nil))
(insn 215 214 216 ../../src/log2.c:118 (set (reg:SI 25 %r25)
(reg:SI 182)) -1 (expr_list:REG_EQUAL (symbol_ref:SI
("__gmpfr_cache_const_log2") [flags 0x50] <var_decl 0x402b2630
__gmpfr_cache_const_log2>)
(nil)))
(insn 216 215 217 ../../src/log2.c:118 (set (reg:SI 24 %r24)
(const_int 3 [0x3])) -1 (nil))
(call_insn 217 216 0 ../../src/log2.c:118 (parallel [
(set (reg:SI 4 %r4)
(reg:SI 19 %r19))
(set (reg:SI 28 %r28)
(call (mem:SI (symbol_ref/v:SI ("@mpfr_cache") [flags 0x41]
<function_decl 0x402fea00 mpfr_cache>) [0 S4 A32])
(const_int 16 [0x10])))
(clobber (reg:SI 1 %r1))
(clobber (reg:SI 2 %r2))
(use (reg:SI 4 %r4))
(use (reg:SI 19 %r19))
(use (const_int 0 [0x0]))
]) -1 (nil)
(expr_list:REG_DEP_TRUE (use (reg:SI 24 %r24))
(expr_list:REG_DEP_TRUE (use (reg:SI 25 %r25))
(expr_list:REG_DEP_TRUE (use (reg:SI 26 %r26))
(nil)))))
As can be seen, the set in insn 210 is dead.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/50691] Incorrect argument evaluation in call with __thread argument
2011-10-10 19:33 [Bug middle-end/50691] New: Incorrect argument evaluation in call with __thread argument danglin at gcc dot gnu.org
@ 2011-10-10 19:35 ` danglin at gcc dot gnu.org
2011-10-10 20:08 ` danglin at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: danglin at gcc dot gnu.org @ 2011-10-10 19:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50691
--- Comment #1 from John David Anglin <danglin at gcc dot gnu.org> 2011-10-10 19:34:31 UTC ---
Created attachment 25457
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25457
Preprocessed source
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/50691] Incorrect argument evaluation in call with __thread argument
2011-10-10 19:33 [Bug middle-end/50691] New: Incorrect argument evaluation in call with __thread argument danglin at gcc dot gnu.org
2011-10-10 19:35 ` [Bug middle-end/50691] " danglin at gcc dot gnu.org
@ 2011-10-10 20:08 ` danglin at gcc dot gnu.org
2011-10-10 20:18 ` danglin at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: danglin at gcc dot gnu.org @ 2011-10-10 20:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50691
--- Comment #2 from John David Anglin <danglin at gcc dot gnu.org> 2011-10-10 20:08:01 UTC ---
Compile command:
gcc -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DTIME_WITH_SYS_TIME=1
-DHAVE_LOCALE_H=1 -DHAVE_WCHAR_H=1 -DHAVE_STDARG=1 -DHAVE_SYS_TIME_H=1
-DHAVE_ALLOCA_H=1 -DHAVE_STDINT_H=1 -DHAVE_VA_COPY=1 -DHAVE_SETLOCALE=1
-DHAVE_GETTIMEOFDAY=1 -DHAVE_LONG_LONG=1 -DHAVE_INTMAX_T=1
-DMPFR_HAVE_INTMAX_MAX=1 -DMPFR_HAVE_FESETROUND=1 -DHAVE_DENORMS=1
-DHAVE_ROUND=1 -DHAVE_TRUNC=1 -DHAVE_FLOOR=1 -DHAVE_CEIL=1 -DHAVE_NEARBYINT=1
-DMPFR_USE_THREAD_SAFE=1 -DLT_OBJDIR=\".libs/\" -DHAVE_ATTRIBUTE_MODE=1
-DHAVE___GMPN_ROOTREM=1 -DHAVE___GMPN_SBPI1_DIVAPPR_Q=1 -I. -I../../src -g -O3
-MT log2.lo -MD -MP -MF .deps/log2.Tpo -S ../../src/log2.c -fPIC -DPIC -o
.libs/log2.s
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/50691] Incorrect argument evaluation in call with __thread argument
2011-10-10 19:33 [Bug middle-end/50691] New: Incorrect argument evaluation in call with __thread argument danglin at gcc dot gnu.org
2011-10-10 19:35 ` [Bug middle-end/50691] " danglin at gcc dot gnu.org
2011-10-10 20:08 ` danglin at gcc dot gnu.org
@ 2011-10-10 20:18 ` danglin at gcc dot gnu.org
2011-10-21 12:17 ` danglin at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: danglin at gcc dot gnu.org @ 2011-10-10 20:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50691
--- Comment #3 from John David Anglin <danglin at gcc dot gnu.org> 2011-10-10 20:16:23 UTC ---
Created attachment 25459
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25459
Simplified testcase
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/50691] Incorrect argument evaluation in call with __thread argument
2011-10-10 19:33 [Bug middle-end/50691] New: Incorrect argument evaluation in call with __thread argument danglin at gcc dot gnu.org
` (2 preceding siblings ...)
2011-10-10 20:18 ` danglin at gcc dot gnu.org
@ 2011-10-21 12:17 ` danglin at gcc dot gnu.org
2011-10-21 23:16 ` [Bug target/50691] " danglin at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: danglin at gcc dot gnu.org @ 2011-10-21 12:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50691
--- Comment #4 from John David Anglin <danglin at gcc dot gnu.org> 2011-10-21 12:17:11 UTC ---
The following tree is incorrectly expanded bt expand call:
(gdb) p debug_tree (exp)
<call_expr 0x403bf730
type <integer_type 0x4036c3c0 int public SI
size <integer_cst 0x40362510 constant 32>
unit size <integer_cst 0x40362528 constant 4>
align 32 symtab 0 alias set 2 canonical type 0x4036c3c0 precision 32
min <integer_cst 0x40362780 -2147483648> max <integer_cst 0x40362798
2147483647>
pointer_to_this <pointer_type 0x4036cae0>>
side-effects
fn <addr_expr 0x403da738
type <pointer_type 0x403cff00 type <function_type 0x403cfde0>
unsigned SI size <integer_cst 0x40362510 32> unit size <integer_cst
0x40362528 4>
align 32 symtab 0 alias set -1 canonical type 0x403cff00>
constant
arg 0 <function_decl 0x403dbf00 bar type <function_type 0x403cfde0>
addressable used public external decl_5 SI file xxx.c line 2 col 12
align 32 context <translation_unit_decl 0x40377e00 D.1216> chain <function_decl
0x403dbf80 foo>>>
arg 0 <addr_expr 0x403da660
type <pointer_type 0x4036cae0 type <integer_type 0x4036c3c0 int>
unsigned SI size <integer_cst 0x40362510 32> unit size <integer_cst
0x40362528 4>
align 32 symtab 0 alias set -1 canonical type 0x4036cae0>
arg 0 <parm_decl 0x403e30b0 x type <integer_type 0x4036c3c0 int>
addressable used SI file xxx.c line 4 col 10 size <integer_cst
0x40362510 32> unit size <integer_cst 0x40362528 4>
align 32 context <function_decl 0x403dbf80 foo>
(mem/c/i:SI (plus:SI (reg/f:SI 90 virtual-incoming-args)
(const_int -4 [0xfffffffc])) [2 x+0 S4 A32]) arg-type <integer_type
0x4036c3c0 int>
incoming-rtl (reg:SI 26 %r26 [ x ])>
xxx.c:6:14>
arg 1 <addr_expr 0x403da678 type <pointer_type 0x4036cae0>
arg 0 <var_decl 0x403cfd80 y type <integer_type 0x4036c3c0 int>
addressable used public external tls-global-dynamic SI file xxx.c
line 1 col 21 size <integer_cst 0x40362510 32> unit size <integer_cst
0x40362528 4>
align 32 context <translation_unit_decl 0x40377e00 D.1216> chain
<function_decl 0x403dbf00 bar>>
xxx.c:6:14>
xxx.c:6:3>
$11 = void
(gdb) bt
#0 expand_call (exp=0x403bf730, target=0x403bbe50, ignore=0)
at ../../gcc/gcc/calls.c:1965
#1 0x0027bdb0 in expand_expr_real_1 (exp=0x403bf730, target=<optimized out>,
tmode=SImode, modifier=EXPAND_NORMAL, alt_rtl=0xfdf02a08)
at ../../gcc/gcc/expr.c:9934
#2 0x0027a194 in expand_expr_real_1 (exp=0x403bf730, target=<optimized out>,
tmode=SImode, modifier=EXPAND_NORMAL, alt_rtl=0xfdf02a08)
at ../../gcc/gcc/expr.c:9911
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/50691] Incorrect argument evaluation in call with __thread argument
2011-10-10 19:33 [Bug middle-end/50691] New: Incorrect argument evaluation in call with __thread argument danglin at gcc dot gnu.org
` (3 preceding siblings ...)
2011-10-21 12:17 ` danglin at gcc dot gnu.org
@ 2011-10-21 23:16 ` danglin at gcc dot gnu.org
2011-10-29 15:57 ` danglin at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: danglin at gcc dot gnu.org @ 2011-10-21 23:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50691
John David Anglin <danglin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|middle-end |target
--- Comment #5 from John David Anglin <danglin at gcc dot gnu.org> 2011-10-21 23:16:08 UTC ---
Testing a change to pa_legitimate_constant_p.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/50691] Incorrect argument evaluation in call with __thread argument
2011-10-10 19:33 [Bug middle-end/50691] New: Incorrect argument evaluation in call with __thread argument danglin at gcc dot gnu.org
` (4 preceding siblings ...)
2011-10-21 23:16 ` [Bug target/50691] " danglin at gcc dot gnu.org
@ 2011-10-29 15:57 ` danglin at gcc dot gnu.org
2011-10-29 20:20 ` danglin at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: danglin at gcc dot gnu.org @ 2011-10-29 15:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50691
--- Comment #6 from John David Anglin <danglin at gcc dot gnu.org> 2011-10-29 15:57:04 UTC ---
Author: danglin
Date: Sat Oct 29 15:57:00 2011
New Revision: 180655
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180655
Log:
PR target/50691
config/pa/pa.c (emit_move_sequence): Legitimize TLS symbol references.
(pa_legitimate_constant_p): Return false for TLS_MODEL_GLOBAL_DYNAMIC
and TLS_MODEL_LOCAL_DYNAMIC symbol references.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/pa/pa.c
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/50691] Incorrect argument evaluation in call with __thread argument
2011-10-10 19:33 [Bug middle-end/50691] New: Incorrect argument evaluation in call with __thread argument danglin at gcc dot gnu.org
` (5 preceding siblings ...)
2011-10-29 15:57 ` danglin at gcc dot gnu.org
@ 2011-10-29 20:20 ` danglin at gcc dot gnu.org
2011-10-29 21:29 ` danglin at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: danglin at gcc dot gnu.org @ 2011-10-29 20:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50691
--- Comment #7 from John David Anglin <danglin at gcc dot gnu.org> 2011-10-29 20:19:46 UTC ---
Author: danglin
Date: Sat Oct 29 20:19:38 2011
New Revision: 180662
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180662
Log:
PR target/50691
* config/pa/pa.c (emit_move_sequence): Legitimize TLS symbol references.
* config/pa/pa.h (LEGITIMATE_CONSTANT_P): Return false for
TLS_MODEL_GLOBAL_DYNAMIC and TLS_MODEL_LOCAL_DYNAMIC symbol references.
Modified:
branches/gcc-4_6-branch/gcc/ChangeLog
branches/gcc-4_6-branch/gcc/config/pa/pa.c
branches/gcc-4_6-branch/gcc/config/pa/pa.h
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/50691] Incorrect argument evaluation in call with __thread argument
2011-10-10 19:33 [Bug middle-end/50691] New: Incorrect argument evaluation in call with __thread argument danglin at gcc dot gnu.org
` (6 preceding siblings ...)
2011-10-29 20:20 ` danglin at gcc dot gnu.org
@ 2011-10-29 21:29 ` danglin at gcc dot gnu.org
2011-10-30 3:22 ` danglin at gcc dot gnu.org
2011-10-30 3:24 ` danglin at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: danglin at gcc dot gnu.org @ 2011-10-29 21:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50691
--- Comment #8 from John David Anglin <danglin at gcc dot gnu.org> 2011-10-29 21:29:00 UTC ---
Author: danglin
Date: Sat Oct 29 21:28:57 2011
New Revision: 180664
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180664
Log:
PR target/50691
* config/pa/pa.c (emit_move_sequence): Legitimize TLS symbol references.
* config/pa/pa.h (LEGITIMATE_CONSTANT_P): Return false for
TLS_MODEL_GLOBAL_DYNAMIC and TLS_MODEL_LOCAL_DYNAMIC symbol references.
Modified:
branches/gcc-4_5-branch/gcc/ChangeLog
branches/gcc-4_5-branch/gcc/config/pa/pa.c
branches/gcc-4_5-branch/gcc/config/pa/pa.h
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/50691] Incorrect argument evaluation in call with __thread argument
2011-10-10 19:33 [Bug middle-end/50691] New: Incorrect argument evaluation in call with __thread argument danglin at gcc dot gnu.org
` (7 preceding siblings ...)
2011-10-29 21:29 ` danglin at gcc dot gnu.org
@ 2011-10-30 3:22 ` danglin at gcc dot gnu.org
2011-10-30 3:24 ` danglin at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: danglin at gcc dot gnu.org @ 2011-10-30 3:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50691
--- Comment #9 from John David Anglin <danglin at gcc dot gnu.org> 2011-10-30 03:21:49 UTC ---
Author: danglin
Date: Sun Oct 30 03:21:45 2011
New Revision: 180672
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180672
Log:
PR target/50691
* config/pa/pa.c (emit_move_sequence): Legitimize TLS symbol references.
* config/pa/pa.h (LEGITIMATE_CONSTANT_P): Return false for
TLS_MODEL_GLOBAL_DYNAMIC and TLS_MODEL_LOCAL_DYNAMIC symbol references.
Modified:
branches/gcc-4_4-branch/gcc/ChangeLog
branches/gcc-4_4-branch/gcc/config/pa/pa.c
branches/gcc-4_4-branch/gcc/config/pa/pa.h
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/50691] Incorrect argument evaluation in call with __thread argument
2011-10-10 19:33 [Bug middle-end/50691] New: Incorrect argument evaluation in call with __thread argument danglin at gcc dot gnu.org
` (8 preceding siblings ...)
2011-10-30 3:22 ` danglin at gcc dot gnu.org
@ 2011-10-30 3:24 ` danglin at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: danglin at gcc dot gnu.org @ 2011-10-30 3:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50691
John David Anglin <danglin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
--- Comment #10 from John David Anglin <danglin at gcc dot gnu.org> 2011-10-30 03:24:44 UTC ---
Fixed.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-10-30 3:24 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-10 19:33 [Bug middle-end/50691] New: Incorrect argument evaluation in call with __thread argument danglin at gcc dot gnu.org
2011-10-10 19:35 ` [Bug middle-end/50691] " danglin at gcc dot gnu.org
2011-10-10 20:08 ` danglin at gcc dot gnu.org
2011-10-10 20:18 ` danglin at gcc dot gnu.org
2011-10-21 12:17 ` danglin at gcc dot gnu.org
2011-10-21 23:16 ` [Bug target/50691] " danglin at gcc dot gnu.org
2011-10-29 15:57 ` danglin at gcc dot gnu.org
2011-10-29 20:20 ` danglin at gcc dot gnu.org
2011-10-29 21:29 ` danglin at gcc dot gnu.org
2011-10-30 3:22 ` danglin at gcc dot gnu.org
2011-10-30 3:24 ` danglin at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).