Author: yug Date: 2012-03-22 04:19:35 -0400 (Thu, 22 Mar 2012) New Revision: 3888
Modified: trunk/osprey/be/cg/x8664/cgtarget.cxx trunk/osprey/be/cg/x8664/exp_loadstore.cxx Log: fix for bug955(the regression caused by r3882). we try to avoid the abuse of TN_RELOC_IA32_GOTOFF in -fpic code, resolve back to use IA32_GOT as r3881 did. Only for those cases have to change to IA32_GOTOFF, i.e, sym:base+ofst expanded to two CGIR ops, and needit be restored for Asm_m_constrint, we do it. Code Review: Lai Jian-Xin. Modified: trunk/osprey/be/cg/x8664/cgtarget.cxx =================================================================== --- trunk/osprey/be/cg/x8664/cgtarget.cxx 2012-03-19 08:54:08 UTC (rev 3887) +++ trunk/osprey/be/cg/x8664/cgtarget.cxx 2012-03-22 08:19:35 UTC (rev 3888) @@ -4022,10 +4022,32 @@ OP* lda_op = OPS_last( ops ); // open64.net bug951. On finding the symbol TN, don't miss the cases of: // TN :- ld32 GTN2(%rbx) (sym:base_sym +0) - // TN :- lea32 GTN2(%rbx) (sym:base_sym+base_ofst) + // and + // TN_tmp :- ld32 GTN2(%rbx) (sym:base_sym +0) + // TN :- lea32 TN_tmp ofst_TN + // result_sym of the first case is + // (sym:base_sym + 0), reloc: TN_RELOC_IA32_GOT + // result_sym of the latter case is + // (sym:base_sym + base_ofst), reloc: TN_RELOC_IA32_GOTOFF + if (Is_Target_32bit() && Gen_PIC_Shared) { - asm_opnd = OP_iadd(lda_op) ? OP_opnd( lda_op, 1 ) : - (OP_code(lda_op) == TOP_ldc32) ? OP_opnd( lda_op, 0) : OP_opnd( lda_op, 1); + OP * prev_lda = OP_prev(lda_op); + if (OP_code(lda_op) == TOP_lea32 && + prev_lda && + OP_code(prev_lda) == TOP_ld32 && + TN_is_constant(OP_opnd(lda_op, 1)) && + TN_register(OP_opnd(lda_op, 0)) == TN_register(OP_result(prev_lda, 0)) && + TN_is_symbol(OP_opnd(prev_lda, 1)) && + TN_relocs(OP_opnd(prev_lda, 1)) == TN_RELOC_IA32_GOT) { + asm_opnd = Gen_Symbol_TN( TN_var(OP_opnd(prev_lda, 1)), + TN_value(OP_opnd(lda_op, 1)), + TN_RELOC_IA32_GOTOFF ); + OPS_Remove_Op (ops, prev_lda); + } + else if (OP_code(lda_op) == TOP_ldc32) + asm_opnd = OP_opnd( lda_op, 0); + else + asm_opnd = OP_opnd( lda_op, 1 ); } else { asm_opnd = OP_iadd(lda_op) ? OP_opnd( lda_op, 1 ) : OP_opnd( lda_op, 0 ); } Modified: trunk/osprey/be/cg/x8664/exp_loadstore.cxx =================================================================== --- trunk/osprey/be/cg/x8664/exp_loadstore.cxx 2012-03-19 08:54:08 UTC (rev 3887) +++ trunk/osprey/be/cg/x8664/exp_loadstore.cxx 2012-03-22 08:19:35 UTC (rev 3888) @@ -1267,29 +1267,17 @@ STB_section(base_sym) /* bug 10097 */)) ){ FmtAssert(!ST_is_thread_local(base_sym), ("Exp_Ldst: thread-local storage NYI under PIC")); - - // open64.net bug951. - // when base_ofst ! = 0, we generate - // TN :- lea32 GTN2(%rbx) (sym:base_sym+base_ofst) - // instead of - // tmp_TN :- ld32 GT2(%bx) (sym:base_sym + 0) - // TN :- lea32 tmp_TN base_ofst - // this is for consideration of facilitate restoring the register TN - // to symbol TN in ASM m constraint. - // And also this reduces a temp TN. - - if (base_ofst == 0) - Build_OP( TOP_ld32, tn, Ebx_TN(), - Gen_Symbol_TN( base_sym, base_ofst, TN_RELOC_IA32_GOT ), - &newops ); - else - Build_OP( TOP_lea32, tn, Ebx_TN(), - Gen_Symbol_TN( base_sym, base_ofst, TN_RELOC_IA32_GOTOFF ), - &newops ); + TN* tmp = base_ofst == 0 ? tn : Build_TN_Like(tn); + Build_OP( TOP_ld32, tmp, Ebx_TN(), + Gen_Symbol_TN( base_sym, 0, TN_RELOC_IA32_GOT ), + &newops ); // got address should not alias Set_OP_no_alias(OPS_last(&newops)); PU_References_GOT = TRUE; + if( base_ofst != 0 ){ + Build_OP( TOP_lea32, tn, tmp, Gen_Literal_TN(base_ofst, 4), &newops ); + } } else { Build_OP( TOP_ldc32, tn, Gen_Symbol_TN( base_sym, base_ofst, TN_RELOC_NONE ), ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ Open64-devel mailing list Open64-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open64-devel