On Tue, Jan 21, 2020 at 8:16 PM H.J. Lu <hjl.to...@gmail.com> wrote:
>
> On Tue, Jan 21, 2020 at 2:29 AM Uros Bizjak <ubiz...@gmail.com> wrote:
> >
> > On Tue, Jan 21, 2020 at 9:47 AM Uros Bizjak <ubiz...@gmail.com> wrote:
> > >
> > > On Mon, Jan 20, 2020 at 10:46 PM H.J. Lu <hjl.to...@gmail.com> wrote:
> > >
> > > > > > OK. Let's go with this version, but please investigate if we need to
> > > > > > calculate TLS address in ptr_mode instead of Pmode. Due to quite 
> > > > > > some
> > > > > > zero-extension from ptr_mode to Pmode hacks in this area, it looks 
> > > > > > to
> > > > > > me that the whole calculation should be performed in ptr_mode 
> > > > > > (SImode
> > > > > > in case of x32), and the result zero-extended to Pmode in case when
> > > > > > Pmode = DImode.
> > > > > >
> > > > >
> > > > > I checked it in.  I will investigate if we can use ptr_mode for TLS.
> > > >
> > > > Here is a patch to perform GNU2 TLS address computation in ptr_mode
> > > > and zero-extend result to Pmode.
> > >
> > >      case TLS_MODEL_GLOBAL_DYNAMIC:
> > > -      dest = gen_reg_rtx (Pmode);
> > > +      dest = gen_reg_rtx (TARGET_GNU2_TLS ? ptr_mode : Pmode);
> > >
> > > Please put these in their respective arms of "if (TARGET_GNU2_TLS).
> > >
> > >      case TLS_MODEL_LOCAL_DYNAMIC:
> > > -      base = gen_reg_rtx (Pmode);
> > > +      base = gen_reg_rtx (TARGET_GNU2_TLS ? ptr_mode : Pmode);
> > >
> > > Also here.
> > >
> > > A question: Do we need to emit the following part in Pmode?
> >
> > To answer my own question: Yes. Linker doesn't like SImode relocs fox
> > x86_64 and for
> >
> > addl    $foo@dtpoff, %eax
> >
> > errors out with:
> >
> > pr93319-1a.s: Assembler messages:
> > pr93319-1a.s:20: Error: relocated field and relocation type differ in 
> > signedness
> >
> > So, the part below is OK, except:
> >
> > -      tp = get_thread_pointer (Pmode, true);
> > -      set_unique_reg_note (get_last_insn (), REG_EQUAL,
> > -                   gen_rtx_MINUS (Pmode, tmp, tp));
> > +      tp = get_thread_pointer (ptr_mode, true);
> > +      tmp = gen_rtx_MINUS (ptr_mode, tmp, tp);
> > +      if (GET_MODE (tmp) != Pmode)
> > +        tmp = gen_rtx_ZERO_EXTEND (Pmode, tmp);
> > +      set_unique_reg_note (get_last_insn (), REG_EQUAL, tmp);
> >
> > I don't think we should attach this note to the thread pointer
> > initialization. I have removed this part from the patch, but please
> > review the decision.
> >
> > and
> >
> > -        dest = gen_rtx_PLUS (Pmode, tp, dest);
> > +        dest = gen_rtx_PLUS (ptr_mode, tp, dest);
> >
> > Please leave Pmode here. ptr_mode == Pmode at this point, but Pmode
> > better documents the mode selection logic.
> >
> > Also, the tests fail for me with:
> >
> > /usr/include/gnu/stubs.h:13:11: fatal error: gnu/stubs-x32.h: No such
> > file or directory
> >
> > so either use __builtin_printf or some other approach that doesn't
> > need to #include stdio.h.
> >
> > A patch that implements above changes is attached to the message.
> >
>
> Here is the updated patch.  OK for master?

OK if it passes regtests.

Thanks,
Uros.

Reply via email to