[llvm-bugs] [Bug 33065] New: false(?) -Wsequence warning
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue May 16 19:55:21 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=33065
Bug ID: 33065
Summary: false(?) -Wsequence warning
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: libclang
Assignee: unassignedclangbugs at nondot.org
Reporter: ndesaulniers at google.com
CC: klimek at google.com, llvm-bugs at lists.llvm.org
Created attachment 18452
--> https://bugs.llvm.org/attachment.cgi?id=18452&action=edit
.config
>From this LKML thread: https://lkml.org/lkml/2017/5/10/45
I had a hard time pairing down a smaller test case to reproduce; I'm sorry.
The best STR I could come up with:
1. git clone https://github.com/nickdesaulniers/linux.git --depth=1 -b
llvm-bugreport1 --single-branch
2. cd linux
3, <download attached .config file, save to linux/.config>
4. make CC=clang HOSTCC=clang -j4 mm/vmscan.o
produces the warning:
mm/vmscan.c:2961:25: warning: unsequenced modification and access to 'gfp_mask'
[-Wunsequenced]
.gfp_mask = (gfp_mask = current_gfp_context(gfp_mask)),
^
For the following code (now modified upstream, which is why I maintain my
fork+branch):
2955 unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
2956 gfp_t gfp_mask, nodemask_t *nodemask)
2957 {
2958 unsigned long nr_reclaimed;
2959 struct scan_control sc = {
2960 .nr_to_reclaim = SWAP_CLUSTER_MAX,
2961 .gfp_mask = (gfp_mask = current_gfp_context(gfp_mask)),
2962 .reclaim_idx = gfp_zone(gfp_mask),
2963 .order = order,
2964 .nodemask = nodemask,
2965 .priority = DEF_PRIORITY,
2966 .may_writepage = !laptop_mode,
2967 .may_unmap = 1,
2968 .may_swap = 1,
2969 };
...
and current_gfp_context() is defined as:
157 static inline gfp_t current_gfp_context(gfp_t flags)
158 {
159 /*
160 * NOIO implies both NOIO and NOFS and it is a weaker context
161 * so always make sure it makes precendence
162 */
163 if (unlikely(current->flags & PF_MEMALLOC_NOIO))
164 flags &= ~(__GFP_IO | __GFP_FS);
165 else if (unlikely(current->flags & PF_MEMALLOC_NOFS))
166 flags &= ~__GFP_FS;
167 return flags;
168 }
in include/linux/sched/mm.h
and unlikely is defined as:
146 # ifndef likely
147 # define likely(x) (__branch_check__(x, 1, __builtin_constant_p(x)))
148 # endif
149 # ifndef unlikely
150 # define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x)))
151 # endif
in include/linux/compiler.h
and __branch_check__ is defined as
125 #define __branch_check__(x, expect, is_constant) ({ \
126 int ______r; \
127 static struct ftrace_likely_data \
128 __attribute__((__aligned__(4))) \
129 __attribute__((section("_ftrace_annotated_branch"))) \
130 ______f = { \
131 .data.func = __func__, \
132 .data.file = __FILE__, \
133 .data.line = __LINE__, \
134 }; \
135 ______r = __builtin_expect(!!(x), expect); \
136 ftrace_likely_update(&______f, ______r, \
137 expect, is_constant); \
138 ______r; \
139 })
By running (make sure to `rm/vmscan.o` between rebuilds):
time make CC=clang HOSTCC=clang V=1 -j4 mm/vmscan.o
we can see that the full compiler flags used are:
clang -Wp,-MD,mm/.vmscan.o.d -nostdinc -isystem
/usr/lib/llvm-4.0/bin/../lib/clang/4.0.0/include -I./arch/x86/include
-I./arch/x86/include/generated/uapi -I./arch/x86/include/generated -I./include
-I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include
./include/linux/kconfig.h -D__KERNEL__ -no-integrated-as -Qunused-arguments
-Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
-fno-common -Werror-implicit-function-declaration -Wno-format-security
-std=gnu89 -fno-PIE -no-integrated-as -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
-mno-avx -m64 -mno-80387 -mtune=generic -mno-red-zone -mcmodel=kernel
-funit-at-a-time -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1
-DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1
-DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1
-DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe
-Wno-sign-compare -fno-asynchronous-unwind-tables -O2 -Wframe-larger-than=1024
-fno-stack-protector -Wno-unused-variable -Wno-format-invalid-specifier
-Wno-gnu -Wno-asm-operand-widths -Wno-initializer-overrides -fno-builtin
-Wno-tautological-compare -mno-global-merge -fno-omit-frame-pointer
-fno-optimize-sibling-calls -g -gdwarf-4 -pg -Wdeclaration-after-statement
-Wno-pointer-sign -fno-strict-overflow -Werror=implicit-int
-Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types
-Wno-initializer-overrides -Wno-unused-value -Wno-format
-Wno-unknown-warning-option -Wno-sign-compare -Wno-format-zero-length
-Wno-uninitialized -DKBUILD_BASENAME='"vmscan"' -DKBUILD_MODNAME='"vmscan"'
-c -o mm/vmscan.o mm/vmscan.c
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170517/6b281b6c/attachment.html>
More information about the llvm-bugs
mailing list