From: Jakub Kicinski <kubakici@wp.pl>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH] new byteorder primitives - ..._{replace,get}_bits()
Date: Tue, 12 Dec 2017 18:44:00 -0800 [thread overview]
Message-ID: <20171212184400.13b27cf8@cakuba.netronome.com> (raw)
In-Reply-To: <20171213015125.GC21978@ZenIV.linux.org.uk>
On Wed, 13 Dec 2017 01:51:25 +0000, Al Viro wrote:
> On Tue, Dec 12, 2017 at 05:35:28PM -0800, Jakub Kicinski wrote:
>
> > It used to be __always_inline, but apparently LLVM/clang doesn't
> > propagate constants :(
> >
> > 4e59532541c8 ("nfp: don't depend on compiler constant propagation")
>
> Doesn't propagate constants or doesn't have exact same set of
> rules for __builtin_constant_p()? IOW, if you dropped that
> BUILD_BUG_ON(), what would be left after optimizations?
Hm. You're right. It just doesn't recognize the parameter as constant
in __builtin_constant_p(). I haven't compiled the actual code, but
here is a trivial test:
18:36 ~$ clang --version
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
18:36 ~$ cat /tmp/test.c
#include <stdio.h>
static inline int test_thing(unsigned int a)
{
printf("const: %d\n", __builtin_constant_p(a));
if (a > 10)
return a - 1;
return a;
}
int main()
{
printf("const: %d\n", __builtin_constant_p(0));
return test_thing(0);
}
18:36 ~$ clang -g /tmp/test.c -O2 -Wall -W -o /tmp/test
18:36 ~$ /tmp/test
const: 1
const: 0
18:36 ~$ objdump -S /tmp/test
...
00000000004004e0 <main>:
return a;
}
int main()
{
printf("const: %d\n", __builtin_constant_p(0));
4004e0: 50 push %rax
4004e1: bf a0 05 40 00 mov $0x4005a0,%edi
4004e6: be 01 00 00 00 mov $0x1,%esi
4004eb: 31 c0 xor %eax,%eax
4004ed: e8 fe fe ff ff callq 4003f0 <printf@plt>
printf("const: %d\n", __builtin_constant_p(a));
4004f2: bf a0 05 40 00 mov $0x4005a0,%edi
4004f7: 31 f6 xor %esi,%esi
4004f9: 31 c0 xor %eax,%eax
4004fb: e8 f0 fe ff ff callq 4003f0 <printf@plt>
return test_thing(0);
400500: 31 c0 xor %eax,%eax
400502: 59 pop %rcx
400503: c3 retq
400504: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
40050b: 00 00 00
40050e: 66 90 xchg %ax,%ax
...
next prev parent reply other threads:[~2017-12-13 2:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-10 4:53 [RFC][PATCH] apparent big-endian bugs in dwc-xlgmac Al Viro
2017-12-11 4:33 ` Jie Deng
2017-12-11 5:05 ` Al Viro
2017-12-11 5:38 ` Al Viro
2017-12-11 6:46 ` Jie Deng
2017-12-11 15:54 ` [RFC][PATCH] new byteorder primitives - ..._{replace,get}_bits() Al Viro
2017-12-12 4:02 ` Jakub Kicinski
2017-12-12 6:20 ` Al Viro
2017-12-12 19:45 ` Al Viro
2017-12-12 20:04 ` Jakub Kicinski
2017-12-12 23:48 ` Al Viro
2017-12-12 23:59 ` Jakub Kicinski
2017-12-13 0:36 ` Al Viro
2017-12-13 1:04 ` Jakub Kicinski
2017-12-13 1:30 ` Al Viro
2017-12-13 1:35 ` Jakub Kicinski
2017-12-13 1:51 ` Al Viro
2017-12-13 2:44 ` Jakub Kicinski [this message]
2017-12-13 14:22 ` Al Viro
2017-12-13 17:45 ` Al Viro
2017-12-15 2:33 ` [RFC][PATCH] Add primitives for manipulating bitfields both in host- and fixed-endian Al Viro
2017-12-15 5:07 ` Jakub Kicinski
2017-12-15 5:34 ` Al Viro
2017-12-15 16:48 ` [RFC][PATCH v2] " Al Viro
2017-12-13 19:04 ` [RFC][PATCH] new byteorder primitives - ..._{replace,get}_bits() Jakub Kicinski
2017-12-11 6:18 ` [RFC][PATCH] apparent big-endian bugs in dwc-xlgmac Jie Deng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171212184400.13b27cf8@cakuba.netronome.com \
--to=kubakici@wp.pl \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).