Re: [PATCH] x86: support i386 with Clang

2020-05-12 Thread Nick Desaulniers
On Mon, May 11, 2020 at 1:03 PM David Woodhouse wrote: > > On Mon, 2020-05-11 at 13:01 -0700, Linus Torvalds wrote: > > On Mon, May 11, 2020 at 12:52 PM Nick Desaulniers > > wrote: > > > > > > Interesting approach. Researching __builtin_choose_expr, it looks > > > like it was cited as prior art

Re: [PATCH] x86: support i386 with Clang

2020-05-11 Thread Brian Gerst
On Mon, May 11, 2020 at 3:34 PM Brian Gerst wrote: > > On Mon, May 11, 2020 at 2:46 PM Nick Desaulniers > wrote: > > > > On Mon, May 11, 2020 at 11:09 AM Brian Gerst wrote: > > > This looks like the same issue that we just discussed for bitops.h. > > > Add the "b" operand size modifier to force

Re: [PATCH] x86: support i386 with Clang

2020-05-11 Thread Nick Desaulniers
On Mon, May 11, 2020 at 12:34 PM Brian Gerst wrote: > > On Mon, May 11, 2020 at 2:46 PM Nick Desaulniers > wrote: > > > > On Mon, May 11, 2020 at 11:09 AM Brian Gerst wrote: > > > This looks like the same issue that we just discussed for bitops.h. > > > Add the "b" operand size modifier to force

Re: [PATCH] x86: support i386 with Clang

2020-05-11 Thread David Woodhouse
On Mon, 2020-05-11 at 13:01 -0700, Linus Torvalds wrote: > On Mon, May 11, 2020 at 12:52 PM Nick Desaulniers > wrote: > > > > Interesting approach. Researching __builtin_choose_expr, it looks > > like it was cited as prior art for C11's _Generic keyword. > > Well, the thing that made me think t

Re: [PATCH] x86: support i386 with Clang

2020-05-11 Thread Linus Torvalds
On Mon, May 11, 2020 at 12:52 PM Nick Desaulniers wrote: > > Interesting approach. Researching __builtin_choose_expr, it looks > like it was cited as prior art for C11's _Generic keyword. Well, the thing that made me think that __builtin_choose_expr() would work is that unlike the switch stateme

Re: [PATCH] x86: support i386 with Clang

2020-05-11 Thread Nick Desaulniers
On Mon, May 11, 2020 at 11:24 AM Linus Torvalds wrote: > > On Mon, May 11, 2020 at 11:12 AM Linus Torvalds > wrote: > > > > Would using "__builtin_choose_expr()" be able to avoid this whole issue? > > We actually have a fair amount of "pick expression based on size", so > with a few helper macros

Re: [PATCH] x86: support i386 with Clang

2020-05-11 Thread Brian Gerst
On Mon, May 11, 2020 at 2:46 PM Nick Desaulniers wrote: > > On Mon, May 11, 2020 at 11:09 AM Brian Gerst wrote: > > This looks like the same issue that we just discussed for bitops.h. > > Add the "b" operand size modifier to force it to use the 8-bit > > register names (and probably also needs th

Re: [PATCH] x86: support i386 with Clang

2020-05-11 Thread Nick Desaulniers
On Mon, May 11, 2020 at 11:09 AM Brian Gerst wrote: > This looks like the same issue that we just discussed for bitops.h. > Add the "b" operand size modifier to force it to use the 8-bit > register names (and probably also needs the "w" modifier in the 16-bit > case). While it does feel familiar,

Re: [PATCH] x86: support i386 with Clang

2020-05-11 Thread Linus Torvalds
On Mon, May 11, 2020 at 11:24 AM Linus Torvalds wrote: > > I guess I should just test it, since I have that clang tree. No, clang doesn't seem to handle it even with __builtin_choose_expr(), and has that invalid input size for constraint 'qi' even when it's in a side that is never chosen.

Re: [PATCH] x86: support i386 with Clang

2020-05-11 Thread Linus Torvalds
On Mon, May 11, 2020 at 11:12 AM Linus Torvalds wrote: > > Would using "__builtin_choose_expr()" be able to avoid this whole issue? We actually have a fair amount of "pick expression based on size", so with a few helper macros we could make the code look better than the case statements too. Some

Re: [PATCH] x86: support i386 with Clang

2020-05-11 Thread Linus Torvalds
On Mon, May 11, 2020 at 10:24 AM Nick Desaulniers wrote: > > Bumping for comment+review. > > On Mon, May 4, 2020 at 4:03 PM Nick Desaulniers > wrote: > > > > - : "qi" ((pto_T__)(val))); \ > > + : "qi" ((unsigned char)(unsigned long)(val))); \ I find

Re: [PATCH] x86: support i386 with Clang

2020-05-11 Thread Brian Gerst
On Mon, May 11, 2020 at 1:26 PM Nick Desaulniers wrote: > > Bumping for comment+review. > > On Mon, May 4, 2020 at 4:03 PM Nick Desaulniers > wrote: > > > > GCC and Clang are architecturally different, which leads to subtle > > issues for code that's invalid but clearly dead. This can happen wit

Re: [PATCH] x86: support i386 with Clang

2020-05-11 Thread Nick Desaulniers
Bumping for comment+review. On Mon, May 4, 2020 at 4:03 PM Nick Desaulniers wrote: > > GCC and Clang are architecturally different, which leads to subtle > issues for code that's invalid but clearly dead. This can happen with > code that emulates polymorphism with the preprocessor and sizeof. > >

[PATCH] x86: support i386 with Clang

2020-05-04 Thread Nick Desaulniers
GCC and Clang are architecturally different, which leads to subtle issues for code that's invalid but clearly dead. This can happen with code that emulates polymorphism with the preprocessor and sizeof. GCC will perform semantic analysis after early inlining and dead code elimination, so it will n