From mboxrd@z Thu Jan 1 00:00:00 1970 From: "John David Anglin" To: dave@hiauly1.hia.nrc.ca (John David Anglin) Cc: law@redhat.com, mark@codesourcery.com, gcc@gcc.gnu.org Subject: Re: C++ Issue on GCC 3.0 branch Date: Mon, 23 Apr 2001 15:21:00 -0000 Message-id: <200104232221.SAA21738@hiauly1.hia.nrc.ca> References: X-SW-Source: 2001-04/msg01089.html > 0x7adfdbd4 <_ZNSt8ios_base4InitC1Ev+124>: stw r26,-24(sr0,r3) > 0x7adfdbd8 <_ZNSt8ios_base4InitC1Ev+128>: > bl 0x7adfdac8 <__get_eh_context>,rp > 0x7adfdbdc <_ZNSt8ios_base4InitC1Ev+132>: nop > 0x7adfdbe0 <_ZNSt8ios_base4InitC1Ev+136>: ldw 9c(sr0,r3),r19 > 0x7adfdbe4 <_ZNSt8ios_base4InitC1Ev+140>: copy ret0,r20 > 0x7adfdbe8 <_ZNSt8ios_base4InitC1Ev+144>: stws r20,-10(sr0,sp) > 0x7adfdbec <_ZNSt8ios_base4InitC1Ev+148>: fldws -10(sr0,sp),fr22 > 0x7adfdbf0 <_ZNSt8ios_base4InitC1Ev+152>: fstws fr22,-10(sr0,sp) > 0x7adfdbf4 <_ZNSt8ios_base4InitC1Ev+156>: ldws -10(sr0,sp),r1 > 0x7adfdbf8 <_ZNSt8ios_base4InitC1Ev+160>: stw r1,a4(sr0,r3) > 0x7adfdbfc <_ZNSt8ios_base4InitC1Ev+164>: stw r19,9c(sr0,r3) The problem was not my patch. There is a real problem with pic C++ code. The problem is that the "first" save for register r19 comes after the first function call. The initial save of r19 was to meet ABI requirements. The save at 0x7adfdbfc is the real save that was supposed to be used for restoration of r19 after function calls. You can see the problem in the rtl: ;; Function std::ios_base::Init::Init() (note 1 0 6 ("../../../../libstdc++-v3/src/ios.cc") 137 0) (insn 6 1 54 (set (reg/v/u/f:SI 94) (reg:SI 26 %r26)) -1 (nil) (expr_list:REG_EQUIV (mem/u/f:SI (plus:SI (reg/f:SI 89 virtual-incoming-args) (const_int -4 [0xfffffffc])) 0) (nil))) (insn 54 6 43 (use:SI (reg:SI 105)) -1 (nil) (expr_list:REG_EH_CONTEXT (reg:SI 105) (nil))) (insn 43 54 7 (set (reg:SI 103) (reg:SI 19 %r19)) -1 (nil) (nil)) (note 7 43 15 NOTE_INSN_FUNCTION_BEG 0) (note 15 7 17 ("../../../../libstdc++-v3/src/ios.cc") 138 0) As can be seen, the eh context stuff has been pushed to the beginning of the function. We need insn 43 to be at the beginning before the eh context stuff. We try to put the save at the start in hppa_init_pic_save: void hppa_init_pic_save () { rtx insn, picreg; picreg = gen_rtx_REG (word_mode, PIC_OFFSET_TABLE_REGNUM); PIC_OFFSET_TABLE_SAVE_RTX = gen_reg_rtx (Pmode); insn = gen_rtx_SET (VOIDmode, PIC_OFFSET_TABLE_SAVE_RTX, picreg); /* Emit the insn at the beginning of the function after the prologue. */ push_topmost_sequence (); emit_insn_after (insn, last_parm_insn ? last_parm_insn : get_insns ()); pop_topmost_sequence (); } This is called when the first call insn is encountered. Any thoughts on how to fix this? Dave -- J. David Anglin dave.anglin@nrc.ca National Research Council of Canada (613) 990-0752 (FAX: 952-6605)