This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: MEM/u trouble
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>
- Subject: Re: MEM/u trouble
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Fri, 16 Mar 2001 05:08:22 -0500
- Cc: gcc-patches at gcc dot gnu dot org
- References: <10103151141.AA02098@vlsi1.ultra.nyu.edu>
- Reply-To: Jakub Jelinek <jakub at redhat dot com>
On Thu, Mar 15, 2001 at 06:41:51AM -0500, Richard Kenner wrote:
> No, at least my understanding is that THIS is a pointer to the unnamed
> temporary variable which was hanging as arg0 of TARGET_EXPR (that's the
> variable which is constructed)
>
> I don't see that. What I see is an assignment
>
> this = &m;
>
> where the type of "this" is a pointer to the non-constant variant of
> the type of M. I don't see this as related to the TARGET_EXPR at all.
You see a different assignment.
I'll repeat the testcase, since I think it was sent just to you privately:
struct J { int c; J(int j) : c(j) {} };
struct K { int d; K(int k) : d(k) {} K(const J &l) : d(l.c) { d++; d = d * d * d; } };
J u();
struct foo { K h; foo(const K m) : h(m) {} };
foo *f;
void bar() { f = new foo(u()); }
There is no this = &m; assignment, there is this = &unnamed_temporary;
assignment.
The expand_expr's TARGET_EXPR case is called from:
#0 expand_expr (exp=0x401d2880, target=0x401c8970, tmode=SImode, modifier=EXPAND_NORMAL) at ../../gcc/expr.c:8377
#1 0x08204b0d in store_expr (exp=0x401d2880, target=0x401c8970, want_value=1) at ../../gcc/expr.c:4101
#2 0x08204312 in expand_assignment (to=0x401d3af8, from=0x401d2880, want_value=1, suggest_reg=0) at ../../gcc/expr.c:3916
expand_assignment arguments are:
to: constant m
<var_decl 0x401d3af8 m
type <record_type 0x401cc138 K readonly needs-constructing type_1 type_5 SI
size <integer_cst 0x401a2be0 constant 32>
unit size <integer_cst 0x401a2c00 constant 4>
user align 32 symtab 0 alias set -1
fields <field_decl 0x401cbc30 d type <integer_type 0x401a6340 int>
used nonlocal decl_3 SI file m.C line 2
size <integer_cst 0x401a25e0 constant 32>
unit size <integer_cst 0x401a2600 constant 4>
align 32 offset_align 128
offset <integer_cst 0x401a2cc0 constant 0>
bit offset <integer_cst 0x401a2ce0 constant 0> context <record_type 0x401cba90 K> arguments <integer_cst 0x401a2cc0 0> chain <type_decl 0x401cbbc8 K>>
needs-constructor X(constX&) this=(X&) n_parents 0 use_template=0 interface-unknown vtable-needs-writing
member-functions <tree_vec 0x401ca700
elt 0 <overload 0x401c8440>
elt 2 <function_decl 0x401cc680 operator=>
elt 3 <overload 0x401c84a0>
elt 4 <overload 0x401c8490>>
pointer_to_this <pointer_type 0x401d1a28> reference_to_this <reference_type 0x401cc1a0>>
readonly used SI file m.C line 4 size <integer_cst 0x401a2be0 32> unit size <integer_cst 0x401a2c00 4>
user align 32 context <function_decl 0x401d3138 bar> abstract_origin <parm_decl 0x401cec30 m>
(reg/v/u:SI 62)>
from: TARGET_EXPR with arg0 unnamed non-constant temporary:
<var_decl 0x401d3888
type <record_type 0x401cba90 K needs-constructing type_1 type_5 SI
size <integer_cst 0x401a2be0 constant 32>
unit size <integer_cst 0x401a2c00 constant 4>
user align 32 symtab 0 alias set -1
fields <field_decl 0x401cbc30 d type <integer_type 0x401a6340 int>
used nonlocal decl_3 SI file m.C line 2
size <integer_cst 0x401a25e0 constant 32>
unit size <integer_cst 0x401a2600 constant 4>
align 32 offset_align 128
offset <integer_cst 0x401a2cc0 constant 0>
bit offset <integer_cst 0x401a2ce0 constant 0> context <record_type 0x401cba90 K> arguments <integer_cst 0x401a2cc0 0> chain <type_decl 0x401cbbc8 K>>
needs-constructor X(constX&) this=(X&) n_parents 0 use_template=0 interface-unknown vtable-needs-writing
member-functions <tree_vec 0x401ca700
elt 0 <overload 0x401c8440>
elt 2 <function_decl 0x401cc680 operator=>
elt 3 <overload 0x401c84a0>
elt 4 <overload 0x401c8490>>
pointer_to_this <pointer_type 0x401cbaf8> reference_to_this <reference_type 0x401cc478> chain <type_decl 0x401cbb60 K>>
addressable used SI file m.C line 6 size <integer_cst 0x401a2be0 32> unit size <integer_cst 0x401a2c00 4>
user align 32 context <function_decl 0x401d3138 bar>>
Now expand_expr on the problematic place decides that it can initialize the
temporary variable in m location, so it SET_DECL_RTL(slot, target)
(target at this point is (reg/v/u:SI 62). As 0x401d3888 is addressable, it
is then push_var_into_stack, so (reg/v/u:SI 62) is replaced with
(mem/s/u:SI (addressof:SI (reg/v/u:SI 63) 62 0x401d3888) 0)
Now later on there is a second interesting assignment you were speaking
about, the one which results in:
(insn 36 34 38 (set (reg/v/f:SI 64)
(addressof:SI (reg/v/u:SI 63) 62 0x401d3888)) -1 (nil)
(nil))
This one is created from:
#0 make_insn_raw (pattern=0x401c89b0) at ../../gcc/emit-rtl.c:2499
#1 0x081e92c3 in emit_insn (pattern=0x401c89b0) at ../../gcc/emit-rtl.c:3248
#2 0x082011c1 in emit_move_insn_1 (x=0x401c89a0, y=0x401c8990) at ../../gcc/expr.c:2774
#3 0x082010d2 in emit_move_insn (x=0x401c89a0, y=0x401c8990) at ../../gcc/expr.c:2747
#4 0x08205696 in store_expr (exp=0x401d4618, target=0x401c89a0, want_value=0) at ../../gcc/expr.c:4278
#5 0x08204312 in expand_assignment (to=0x401d3b60, from=0x401d4618, want_value=0, suggest_reg=0) at ../../gcc/expr.c:3916
where 0x401c89a0 is (reg/v/f:SI 64) and 0x401c8990 is (addressof:SI (reg/v/u:SI 63) 62 0x401d3888).
The expand_assignment in question is:
to:
<var_decl 0x401d3b60 this
type <pointer_type 0x401cbe38
type <record_type 0x401cba90 K needs-constructing type_1 type_5 SI
size <integer_cst 0x401a2be0 constant 32>
unit size <integer_cst 0x401a2c00 constant 4>
user align 32 symtab 0 alias set 0 fields <field_decl 0x401cbc30 d>
needs-constructor X(constX&) this=(X&) n_parents 0 use_template=0 interface-unknown vtable-needs-writing
member-functions <tree_vec 0x401ca700
elt 0 <overload 0x401c8440>
elt 2 <function_decl 0x401cc680 operator=>
elt 3 <overload 0x401c84a0>
elt 4 <overload 0x401c8490>>
pointer_to_this <pointer_type 0x401cbaf8> reference_to_this <reference_type 0x401cc478> chain <type_decl 0x401cbb60 K>>
readonly unsigned SI size <integer_cst 0x401a2be0 32> unit size <integer_cst 0x401a2c00 4>
align 32 symtab 0 alias set -1>
readonly unsigned used SI file m.C line 2 size <integer_cst 0x401a2be0 32> unit size <integer_cst 0x401a2c00 4>
align 32 context <function_decl 0x401d3138 bar> abstract_origin <parm_decl 0x401cc0d0 this> initial <addr_expr 0x401d4618>
(reg/v/f:SI 64) chain <var_decl 0x401d3bc8 l>>
from:
<addr_expr 0x401d4618
type <pointer_type 0x401cbaf8
type <record_type 0x401cba90 K needs-constructing type_1 type_5 SI
size <integer_cst 0x401a2be0 constant 32>
unit size <integer_cst 0x401a2c00 constant 4>
user align 32 symtab 0 alias set 0 fields <field_decl 0x401cbc30 d>
needs-constructor X(constX&) this=(X&) n_parents 0 use_template=0 interface-unknown vtable-needs-writing
member-functions <tree_vec 0x401ca700
elt 0 <overload 0x401c8440>
elt 2 <function_decl 0x401cc680 operator=>
elt 3 <overload 0x401c84a0>
elt 4 <overload 0x401c8490>>
pointer_to_this <pointer_type 0x401cbaf8> reference_to_this <reference_type 0x401cc478> chain <type_decl 0x401cbb60 K>>
unsigned SI size <integer_cst 0x401a2be0 32> unit size <integer_cst 0x401a2c00 4>
align 32 symtab 0 alias set -1>
arg 0 <var_decl 0x401d3888 type <record_type 0x401cba90 K>
addressable used SI file m.C line 6 size <integer_cst 0x401a2be0 32> unit size <integer_cst 0x401a2c00 4>
user align 32 context <function_decl 0x401d3138 bar>
(mem/s/u:SI (addressof:SI (reg/v/u:SI 63) 62 0x401d3888) 0)>>
ie. this = &unnamed_temporary; where this is a pointer to non-const class K
object and unnamed_temporary is a non-const temporary of type K.
The only problem here is that this unnamed_temporary has /u DECL_RTL, and
that was set in expand_expr's TARGET_EXPR case. So IMHO it is really related
to that piece of expand_expr.
Jakub