search for: __builtin_constant_p

Displaying 20 results from an estimated 135 matches for "__builtin_constant_p".

2009 Mar 15
2
[LLVMdev] [Bug 3756] __attribute__((always_inline)) and __builtin_constant_p
...Status|NEW |RESOLVED > Resolution| |WONTFIX > > --- Comment #6 from Chris Lattner <clattner at apple.com> 2009-03-10 23:13:33 --- > Unfortunately, this will never be fixed in either llvm-gcc or clang. > __builtin_constant_p is a "best effort" constant folding tester, which is > allowed to fail. You should never write code that assumes that > __builtin_constant_p can't fail (if you need that, just don't use > __builtin_constant_p). > It would be interesting and useful to bring this up o...
2009 Mar 16
0
[LLVMdev] [Bug 3756] __attribute__((always_inline)) and __builtin_constant_p
...|NEW |RESOLVED >> Resolution| |WONTFIX >> >> --- Comment #6 from Chris Lattner <clattner at apple.com> 2009-03-10 23:13:33 --- >> Unfortunately, this will never be fixed in either llvm-gcc or clang. >> __builtin_constant_p is a "best effort" constant folding tester, which is >> allowed to fail. You should never write code that assumes that >> __builtin_constant_p can't fail (if you need that, just don't use >> __builtin_constant_p). > > >> It would be interesting and...
2018 Apr 12
3
[RFC] __builtin_constant_p() Improvements
Hello again! I took a stab at PR4898[1]. The attached patch improves Clang's __builtin_constant_p support so that the Linux kernel is happy. With this improvement, Clang can determine if __builtin_constant_p is true or false after inlining. As an example: static __attribute__((always_inline)) int foo(int x) { if (__builtin_constant_p(x)) return 1; return 0; } static __attribute__((always_inl...
2009 Mar 16
3
[LLVMdev] [Bug 3756] __attribute__((always_inline)) and __builtin_constant_p
...OLVED >>> Resolution| |WONTFIX >>> >>> --- Comment #6 from Chris Lattner <clattner at apple.com> 2009-03-10 >>> 23:13:33 --- >>> Unfortunately, this will never be fixed in either llvm-gcc or clang. >>> __builtin_constant_p is a "best effort" constant folding tester, >>> which is >>> allowed to fail. You should never write code that assumes that >>> __builtin_constant_p can't fail (if you need that, just don't use >>> __builtin_constant_p). >> >> &gt...
2019 Mar 08
2
8.0 Regression with __builtin_constant_p.
Hi All, I know we're late in the release process, but I've discovered a regression I believe is serious enough to hold the release [1]. The regression is in usages of `__builtin_constant_p` applied to a dereferenced pointer in a constant expression. In certain cases Clang now rejects this as a non-constant expression [2]. This regression will have a larger impact than it initially appears. libstdc++ 7.1 and newer use `__builtin_constant_p` to implement C++17 `std::char_traits` [4]....
2018 Apr 13
0
[RFC] __builtin_constant_p() Improvements
...nd in some circumstances, rather than always emitting IR if it cannot tell the answer is true. On Thu, Apr 12, 2018 at 5:10 PM Bill Wendling via llvm-dev < llvm-dev at lists.llvm.org> wrote: > Hello again! > > I took a stab at PR4898[1]. The attached patch improves Clang's > __builtin_constant_p support so that the Linux kernel is happy. With this > improvement, Clang can determine if __builtin_constant_p is true or false > after inlining. > > As an example: > > static __attribute__((always_inline)) int foo(int x) { > if (__builtin_constant_p(x)) > return 1; > re...
2019 Mar 08
2
[cfe-dev] 8.0 Regression with __builtin_constant_p.
...elier via cfe-dev < > cfe-dev at lists.llvm.org> wrote: > >> Hi All, >> >> I know we're late in the release process, but I've discovered a >> regression I believe is serious enough to hold the release [1]. >> >> The regression is in usages of `__builtin_constant_p` applied to a >> dereferenced pointer in a constant expression. In certain cases Clang now >> rejects this as a non-constant expression [2]. >> >> This regression will have a larger impact than it initially appears. >> >> libstdc++ 7.1 and newer use `__builtin_co...
2020 Aug 06
0
[vhost:vhost 32/65] drivers/virtio/virtio_input.c:247:3: warning: comparison of distinct pointer types ('typeof (_Generic((virtio_cread_v), __u8: (virtio_cread_v), __le16: (__builtin_constant_p((__u16)((__u16)(__le16)(virtio_cread_v)))
...following tag as appropriate Reported-by: kernel test robot <lkp at intel.com> All warnings (new ones prefixed by >>): >> drivers/virtio/virtio_input.c:247:3: warning: comparison of distinct pointer types ('typeof (_Generic((virtio_cread_v), __u8: (virtio_cread_v), __le16: (__builtin_constant_p((__u16)((__u16)(__le16)(virtio_cread_v))) ? ((__u16)((((__u16)((__u16)(__le16)(virtio_cread_v)) & (__u16)255U) << 8) | (((__u16)((__u16)(__le16)(virtio_cread_v)) & (__u16)65280U) >> 8))) : __fswab16((__u16)(__le16)(virtio_cread_v))), __le32: (__builtin_constant_p((__u32)((__u32)...
2009 Mar 20
0
[LLVMdev] [Bug 3756] __attribute__((always_inline)) and __builtin_constant_p
...Resolution| |WONTFIX >>>> >>>> --- Comment #6 from Chris Lattner <clattner at apple.com> 2009-03-10 >>>> 23:13:33 --- >>>> Unfortunately, this will never be fixed in either llvm-gcc or clang. >>>> __builtin_constant_p is a "best effort" constant folding tester, >>>> which is >>>> allowed to fail. You should never write code that assumes that >>>> __builtin_constant_p can't fail (if you need that, just don't use >>>> __builtin_constant_p). >&...
2017 Feb 15
1
[PATCH] average: change to declare precision, not factor
...efficiency. + */ -#define DECLARE_EWMA(name, _factor, _weight) \ +#define DECLARE_EWMA(name, _precision, _weight_rcp) \ struct ewma_##name { \ unsigned long internal; \ }; \ static inline void ewma_##name##_init(struct ewma_##name *e) \ { \ - BUILD_BUG_ON(!__builtin_constant_p(_factor)); \ - BUILD_BUG_ON(!__builtin_constant_p(_weight)); \ - BUILD_BUG_ON_NOT_POWER_OF_2(_factor); \ - BUILD_BUG_ON_NOT_POWER_OF_2(_weight); \ + BUILD_BUG_ON(!__builtin_constant_p(_precision)); \ + BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \ + /* \ + * Even if you wa...
2017 Feb 15
1
[PATCH] average: change to declare precision, not factor
...efficiency. + */ -#define DECLARE_EWMA(name, _factor, _weight) \ +#define DECLARE_EWMA(name, _precision, _weight_rcp) \ struct ewma_##name { \ unsigned long internal; \ }; \ static inline void ewma_##name##_init(struct ewma_##name *e) \ { \ - BUILD_BUG_ON(!__builtin_constant_p(_factor)); \ - BUILD_BUG_ON(!__builtin_constant_p(_weight)); \ - BUILD_BUG_ON_NOT_POWER_OF_2(_factor); \ - BUILD_BUG_ON_NOT_POWER_OF_2(_weight); \ + BUILD_BUG_ON(!__builtin_constant_p(_precision)); \ + BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \ + /* \ + * Even if you wa...
2017 Dec 01
0
[PATCH v18 05/10] xbitmap: add more operations
.... Why would it be illegal? "@start inclusive" means that the @start will also be included to be cleared. > >> +static inline __always_inline void bitmap_clear(unsigned long *map, >> + unsigned int start, >> + unsigned int nbits) >> +{ >> + if (__builtin_constant_p(nbits) && nbits == 1) >> + __clear_bit(start, map); >> + else if (__builtin_constant_p(start & 7) && IS_ALIGNED(start, 8) && >> + __builtin_constant_p(nbits & 7) && IS_ALIGNED(nbits, 8)) > It looks strange to apply __builtin_constant_p...
2014 Nov 27
4
[PATCH v6 01/46] virtio: add low-level APIs for feature bits
...ks. * @vdev: the device * @fbit: the feature bit */ -static inline bool virtio_has_feature(const struct virtio_device *vdev, +static inline bool __virtio_test_bit(const struct virtio_device *vdev, + unsigned int fbit) +{ + /* Did you forget to fix assumptions on max features? */ + if (__builtin_constant_p(fbit)) + BUILD_BUG_ON(fbit >= 32); + else + BUG_ON(fbit >= 32); + + return test_bit(fbit, vdev->features); +} + +/** + * __virtio_set_bit - helper to set feature bits. For use by transports. + * @vdev: the device + * @fbit: the feature bit + */ +static inline void __virtio_set_bit(struct...
2014 Nov 27
4
[PATCH v6 01/46] virtio: add low-level APIs for feature bits
...ks. * @vdev: the device * @fbit: the feature bit */ -static inline bool virtio_has_feature(const struct virtio_device *vdev, +static inline bool __virtio_test_bit(const struct virtio_device *vdev, + unsigned int fbit) +{ + /* Did you forget to fix assumptions on max features? */ + if (__builtin_constant_p(fbit)) + BUILD_BUG_ON(fbit >= 32); + else + BUG_ON(fbit >= 32); + + return test_bit(fbit, vdev->features); +} + +/** + * __virtio_set_bit - helper to set feature bits. For use by transports. + * @vdev: the device + * @fbit: the feature bit + */ +static inline void __virtio_set_bit(struct...
2014 Mar 19
5
[PATCH] virtio-blk: make the queue depth configurable
...sense to separate this octal permissions >> test into a new macro for other checks in macros like >> CLASS_ATTR, DEVICE_ATTR, SENSOR_ATTR and SENSOR_ATTR_2. OK, I took your bikeshed and re-painted it below. > #define VERIFY_OCTAL_PERMISSIONS(perms) \ > ({ \ > if (__builtin_constant_p(perms)) { \ > BUILD_BUG_ON((perms) < 0); \ > BUILD_BUG_ON((perms) > 0777); \ > /* User perms >= group perms >= other perms */ \ > BUILD_BUG_ON(((perms) >> 6) < (((perms) >> 3) & 7)); \ > BUILD_BUG_ON((((perms) >> 3) & 7) &l...
2014 Mar 19
5
[PATCH] virtio-blk: make the queue depth configurable
...sense to separate this octal permissions >> test into a new macro for other checks in macros like >> CLASS_ATTR, DEVICE_ATTR, SENSOR_ATTR and SENSOR_ATTR_2. OK, I took your bikeshed and re-painted it below. > #define VERIFY_OCTAL_PERMISSIONS(perms) \ > ({ \ > if (__builtin_constant_p(perms)) { \ > BUILD_BUG_ON((perms) < 0); \ > BUILD_BUG_ON((perms) > 0777); \ > /* User perms >= group perms >= other perms */ \ > BUILD_BUG_ON(((perms) >> 6) < (((perms) >> 3) & 7)); \ > BUILD_BUG_ON((((perms) >> 3) & 7) &l...
2018 Sep 07
0
[PATCH] bochs: convert to drm_fb_helper_fbdev_setup/teardown
...hs_pm_suspend': drivers/gpu/drm/bochs/bochs_drv.c:110:15: error: 'struct <anonymous>' has no member named 'initialized' if (bochs->fb.initialized) { ^ include/linux/compiler.h:58:30: note: in definition of macro '__trace_if' if (__builtin_constant_p(!!(cond)) ? !!(cond) : \ ^~~~ >> drivers/gpu/drm/bochs/bochs_drv.c:110:2: note: in expansion of macro 'if' if (bochs->fb.initialized) { ^~ drivers/gpu/drm/bochs/bochs_drv.c:110:15: error: 'struct <anonymous>' has no memb...
2014 Mar 17
2
[PATCH] virtio-blk: make the queue depth configurable
On Mon, 2014-03-17 at 14:25 +1030, Rusty Russell wrote: > Erk, our tests are insufficient. Testbuilding an allmodconfig with this > now: Good idea. > diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h [] > @@ -188,6 +188,9 @@ struct kparam_array > /* Default value instead of permissions? */ \ > static int __param_perm_check_##name
2014 Mar 17
2
[PATCH] virtio-blk: make the queue depth configurable
On Mon, 2014-03-17 at 14:25 +1030, Rusty Russell wrote: > Erk, our tests are insufficient. Testbuilding an allmodconfig with this > now: Good idea. > diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h [] > @@ -188,6 +188,9 @@ struct kparam_array > /* Default value instead of permissions? */ \ > static int __param_perm_check_##name
2014 Nov 28
0
[PATCH v6 01/46] virtio: add low-level APIs for feature bits
...: the feature bit > */ > -static inline bool virtio_has_feature(const struct virtio_device *vdev, > +static inline bool __virtio_test_bit(const struct virtio_device *vdev, > + unsigned int fbit) > +{ > + /* Did you forget to fix assumptions on max features? */ > + if (__builtin_constant_p(fbit)) > + BUILD_BUG_ON(fbit >= 32); > + else > + BUG_ON(fbit >= 32); Does this want to be a helper? Might be overkill, but I'm always wary of changes that need to be applied manually in many different places :) > + > + return test_bit(fbit, vdev->features); > +}...