This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
alpha tls vs gp
- From: Richard Henderson <rth at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 15 Jan 2003 17:51:33 -0800
- Subject: alpha tls vs gp
Found some cases testing glibc where we didn't load the GP
properly for the init-exec tls reference.
r~
* config/alpha/alpha.c (find_lo_sum_using_gp): Rename from find_lo_sum;
also check that GP is being used.
(alpha_find_lo_sum_using_gp): New.
(alpha_does_function_need_gp): Use get_attr_usegp.
* config/alpha/alpha-protos.h: Update.
* config/alpha/alpha.md (attr usegp): New. Annotate patterns
as needed.
Index: alpha-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/alpha/alpha-protos.h,v
retrieving revision 1.42
diff -c -p -d -r1.42 alpha-protos.h
*** alpha-protos.h 20 Dec 2002 19:42:40 -0000 1.42
--- alpha-protos.h 16 Jan 2003 01:07:10 -0000
*************** extern rtx function_arg PARAMS ((CUMULAT
*** 142,147 ****
--- 142,149 ----
extern void alpha_start_function PARAMS ((FILE *, const char *, tree));
extern void alpha_end_function PARAMS ((FILE *, const char *, tree));
+ extern int alpha_find_lo_sum_using_gp PARAMS ((rtx));
+
#ifdef REAL_VALUE_TYPE
extern int check_float_value PARAMS ((enum machine_mode,
REAL_VALUE_TYPE *, int));
Index: alpha.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/alpha/alpha.c,v
retrieving revision 1.288
diff -c -p -d -r1.288 alpha.c
*** alpha.c 15 Jan 2003 03:25:50 -0000 1.288
--- alpha.c 16 Jan 2003 01:07:10 -0000
*************** static rtx alpha_expand_builtin
*** 155,161 ****
PARAMS ((tree, rtx, rtx, enum machine_mode, int));
static void alpha_sa_mask
PARAMS ((unsigned long *imaskP, unsigned long *fmaskP));
! static int find_lo_sum
PARAMS ((rtx *, void *));
static int alpha_does_function_need_gp
PARAMS ((void));
--- 155,161 ----
PARAMS ((tree, rtx, rtx, enum machine_mode, int));
static void alpha_sa_mask
PARAMS ((unsigned long *imaskP, unsigned long *fmaskP));
! static int find_lo_sum_using_gp
PARAMS ((rtx *, void *));
static int alpha_does_function_need_gp
PARAMS ((void));
*************** const struct attribute_spec vms_attribut
*** 6970,6980 ****
#endif
static int
! find_lo_sum (px, data)
rtx *px;
void *data ATTRIBUTE_UNUSED;
{
! return GET_CODE (*px) == LO_SUM;
}
static int
--- 6970,6987 ----
#endif
static int
! find_lo_sum_using_gp (px, data)
rtx *px;
void *data ATTRIBUTE_UNUSED;
{
! return GET_CODE (*px) == LO_SUM && XEXP (*px, 0) == pic_offset_table_rtx;
! }
!
! int
! alpha_find_lo_sum_using_gp (insn)
! rtx insn;
! {
! return for_each_rtx (&PATTERN (insn), find_lo_sum_using_gp, NULL) > 0;
}
static int
*************** alpha_does_function_need_gp ()
*** 7003,7017 ****
for (; insn; insn = NEXT_INSN (insn))
if (INSN_P (insn)
&& GET_CODE (PATTERN (insn)) != USE
! && GET_CODE (PATTERN (insn)) != CLOBBER)
! {
! enum attr_type type = get_attr_type (insn);
! if (type == TYPE_LDSYM || type == TYPE_JSR)
! return 1;
! if (TARGET_EXPLICIT_RELOCS
! && for_each_rtx (&PATTERN (insn), find_lo_sum, NULL) > 0)
! return 1;
! }
return 0;
}
--- 7010,7018 ----
for (; insn; insn = NEXT_INSN (insn))
if (INSN_P (insn)
&& GET_CODE (PATTERN (insn)) != USE
! && GET_CODE (PATTERN (insn)) != CLOBBER
! && get_attr_usegp (insn))
! return 1;
return 0;
}
Index: alpha.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/alpha/alpha.md,v
retrieving revision 1.202
diff -c -p -d -r1.202 alpha.md
*** alpha.md 6 Jan 2003 22:59:24 -0000 1.202
--- alpha.md 16 Jan 2003 01:07:11 -0000
*************** fadd,fmul,fcpys,fdiv,fsqrt,misc,mvi,ftoi
*** 142,147 ****
--- 142,159 ----
(define_attr "length" ""
(const_int 4))
+
+ ;; The USEGP attribute marks instructions that have relocations that use
+ ;; the GP.
+
+ (define_attr "usegp" "no,yes"
+ (cond [(eq_attr "type" "ldsym,jsr")
+ (const_string "yes")
+ (eq_attr "type" "ild,fld,ist,fst")
+ (symbol_ref "alpha_find_lo_sum_using_gp(insn)")
+ ]
+ (const_string "no")))
+
;; Include scheduling descriptions.
*************** fadd,fmul,fcpys,fdiv,fsqrt,misc,mvi,ftoi
*** 402,408 ****
(plus:DI (match_operand:DI 1 "register_operand" "r")
(high:DI (match_operand:DI 2 "local_symbolic_operand" ""))))]
"TARGET_EXPLICIT_RELOCS"
! "ldah %0,%2(%1)\t\t!gprelhigh")
(define_split
[(set (match_operand:DI 0 "register_operand" "")
--- 414,421 ----
(plus:DI (match_operand:DI 1 "register_operand" "r")
(high:DI (match_operand:DI 2 "local_symbolic_operand" ""))))]
"TARGET_EXPLICIT_RELOCS"
! "ldah %0,%2(%1)\t\t!gprelhigh"
! [(set_attr "usegp" "yes")])
(define_split
[(set (match_operand:DI 0 "register_operand" "")
*************** fadd,fmul,fcpys,fdiv,fsqrt,misc,mvi,ftoi
*** 5304,5310 ****
return "lda %0,%2(%1)\t\t!gprel";
else
return "lda %0,%2(%1)\t\t!gprellow";
! })
(define_split
[(set (match_operand:DI 0 "register_operand" "")
--- 5317,5324 ----
return "lda %0,%2(%1)\t\t!gprel";
else
return "lda %0,%2(%1)\t\t!gprellow";
! }
! [(set_attr "usegp" "yes")])
(define_split
[(set (match_operand:DI 0 "register_operand" "")
*************** fadd,fmul,fcpys,fdiv,fsqrt,misc,mvi,ftoi
*** 5426,5432 ****
UNSPEC_DTPREL))]
"HAVE_AS_TLS"
"ldq %0,%2(%1)\t\t!gotdtprel"
! [(set_attr "type" "ild")])
(define_split
[(set (match_operand:DI 0 "register_operand" "")
--- 5440,5447 ----
UNSPEC_DTPREL))]
"HAVE_AS_TLS"
"ldq %0,%2(%1)\t\t!gotdtprel"
! [(set_attr "type" "ild")
! (set_attr "usegp" "yes")])
(define_split
[(set (match_operand:DI 0 "register_operand" "")
*************** fadd,fmul,fcpys,fdiv,fsqrt,misc,mvi,ftoi
*** 5447,5453 ****
UNSPEC_TPREL))]
"HAVE_AS_TLS"
"ldq %0,%2(%1)\t\t!gottprel"
! [(set_attr "type" "ild")])
(define_split
[(set (match_operand:DI 0 "register_operand" "")
--- 5462,5469 ----
UNSPEC_TPREL))]
"HAVE_AS_TLS"
"ldq %0,%2(%1)\t\t!gottprel"
! [(set_attr "type" "ild")
! (set_attr "usegp" "yes")])
(define_split
[(set (match_operand:DI 0 "register_operand" "")
*************** fadd,fmul,fcpys,fdiv,fsqrt,misc,mvi,ftoi
*** 5478,5484 ****
fmov %R1,%0
ldt %0,%1
stt %R1,%0"
! [(set_attr "type" "ilog,iadd,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst")])
;; The 'U' constraint matches symbolic operands on Unicos/Mk. Those should
;; have been split up by the rules above but we shouldn't reject the
--- 5494,5501 ----
fmov %R1,%0
ldt %0,%1
stt %R1,%0"
! [(set_attr "type" "ilog,iadd,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst")
! (set_attr "usegp" "*,*,*,yes,*,*,*,*,*,*")])
;; The 'U' constraint matches symbolic operands on Unicos/Mk. Those should
;; have been split up by the rules above but we shouldn't reject the
*************** fadd,fmul,fcpys,fdiv,fsqrt,misc,mvi,ftoi
*** 5525,5531 ****
stt %R1,%0
ftoit %1,%0
itoft %1,%0"
! [(set_attr "type" "ilog,iadd,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst,ftoi,itof")])
(define_insn "*movdi_fix"
[(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,r,r,m,*f,*f,Q,r,*f")
--- 5542,5549 ----
stt %R1,%0
ftoit %1,%0
itoft %1,%0"
! [(set_attr "type" "ilog,iadd,iadd,iadd,ldsym,ild,ist,fcpys,fld,fst,ftoi,itof")
! (set_attr "usegp" "*,*,*,yes,*,*,*,*,*,*,*,*")])
(define_insn "*movdi_fix"
[(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,r,r,m,*f,*f,Q,r,*f")