[Bug tree-optimization/98110] [11 Regression] dl-lookup.c in glibc is miscompiled by r11-5029

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Dec 3 11:56:57 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98110

--- Comment #15 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #13)
> And no, the asm isn't marked volatile, that would have prevented it too:
> # define THREAD_SELF \
>   ({ struct pthread *__self;                                                
> \
>      asm ("mov %%fs:%c1,%0" : "=r" (__self)                                 
> \
>           : "i" (offsetof (struct pthread, header.self)));                  
> \
>      __self;})
> This all boils down to:
> void
> foo (int *p)
> {
>   for (int i = 0; i < 64; i++)
>     {
>       if (p[i])
> 	{
> 	  int *q;
> 	  asm ("mov %%fs:%c1,%0" : "=r" (q) : "i" (16));
> 	  q[0]++;
> 	}
>     }
> }
> which would hoist the inline asm to the function prologue even in GCC 4.1.

I suppose we'd need to mark it possibly trapping (which it actually does),
but I think there's no good way to do this.


More information about the Gcc-bugs mailing list