Author: yug Date: 2012-03-14 04:51:57 -0400 (Wed, 14 Mar 2012) New Revision: 3882
Modified: trunk/osprey/be/cg/cgemit.cxx trunk/osprey/be/cg/x8664/cgtarget.cxx trunk/osprey/be/cg/x8664/exp_loadstore.cxx Log: fix for bug951. under -m32 -fpic environment, when we do ld_st: 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. Code Review: Lai Jian-Xin. Modified: trunk/osprey/be/cg/cgemit.cxx =================================================================== --- trunk/osprey/be/cg/cgemit.cxx 2012-03-13 08:20:27 UTC (rev 3881) +++ trunk/osprey/be/cg/cgemit.cxx 2012-03-14 08:51:57 UTC (rev 3882) @@ -3346,8 +3346,20 @@ #endif if( base_ofst == 0 ){ #if defined(TARG_X8664) - if( Is_Target_32bit() ) - sprintf( buf, "%s", name ); + // open64.net bug951. + // Format IA32 GOT symbol in Asm_String. + if( Is_Target_32bit() ) { + switch (TN_relocs(tn)) { + case TN_RELOC_IA32_GOT: + sprintf( buf, + "%s@GOT(%s)", + name, + int_reg_names[3][TN_register(Ebx_TN())- REGISTER_MIN]); + break; + default: + sprintf( buf, "%s", name); + } + } else sprintf( buf, "%s(%%rip)", name ); #else @@ -3355,8 +3367,21 @@ #endif } else #if defined(TARG_X8664) - if( Is_Target_32bit() ) - sprintf( buf, "%s+%d", name, (int)base_ofst ); + // open64.net bug951. + // Format IA32 GOTOFF symbol in Asm_String. + if( Is_Target_32bit() ) { + switch (TN_relocs(tn)) { + case TN_RELOC_IA32_GOTOFF: + sprintf( buf, + "%s@GOTOFF+%d(%s)", + name, + (int)base_ofst, + int_reg_names[3][TN_register(Ebx_TN())- REGISTER_MIN]); + break; + default: + sprintf( buf, "%s+%d", name, (int)base_ofst ); + } + } else sprintf( buf, "%s+%d(%%rip)", name, (int)base_ofst ); #else Modified: trunk/osprey/be/cg/x8664/cgtarget.cxx =================================================================== --- trunk/osprey/be/cg/x8664/cgtarget.cxx 2012-03-13 08:20:27 UTC (rev 3881) +++ trunk/osprey/be/cg/x8664/cgtarget.cxx 2012-03-14 08:51:57 UTC (rev 3882) @@ -4020,7 +4020,15 @@ if( WN_operator(load) == OPR_LDA ){ OP* lda_op = OPS_last( ops ); - asm_opnd = OP_iadd(lda_op) ? OP_opnd( lda_op, 1 ) : OP_opnd( lda_op, 0 ); + // 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) + 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); + } else { + asm_opnd = OP_iadd(lda_op) ? OP_opnd( lda_op, 1 ) : OP_opnd( lda_op, 0 ); + } OPS_Remove_Op( ops, lda_op ); } else if( WN_operator(load) == OPR_ADD ){ Modified: trunk/osprey/be/cg/x8664/exp_loadstore.cxx =================================================================== --- trunk/osprey/be/cg/x8664/exp_loadstore.cxx 2012-03-13 08:20:27 UTC (rev 3881) +++ trunk/osprey/be/cg/x8664/exp_loadstore.cxx 2012-03-14 08:51:57 UTC (rev 3882) @@ -1267,17 +1267,29 @@ STB_section(base_sym) /* bug 10097 */)) ){ FmtAssert(!ST_is_thread_local(base_sym), ("Exp_Ldst: thread-local storage NYI under PIC")); - 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 ); + + // 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 ); // 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 ), ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ Open64-devel mailing list Open64-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open64-devel