https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70188
Bug ID: 70188 Summary: gcc 4.9+ miscompiles code on hppa Product: gcc Version: 4.9.4 URL: https://patchwork.kernel.org/patch/8402441/ Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: deller at gmx dot de CC: dave.anglin at bell dot net Target Milestone: --- Target: hppa64-linux-gnu-gcc Linux kernels above 4.3 don't boot any longer when compiled with gcc-4.9 or gcc-5. After some analysis, it seems gcc miscompiles the function blk_bio_segment_split() in block/blk-merge.c. Compiling this function with -O0 or -O1 does produce a functional Linux kernel, but when compiled with -O2 the kernel crashes during SCSI detection. I was able to extract the function from the kernel source and attached is a preprocessed file for easier analysis. It seems the variables bvprv and/or bvprvp get optimized out when compiled with -O2. This command is used to compile the file: hppa64-linux-gnu-gcc-4.9 -Wp,-MD,block/.blk-merge_part.o.d -nostdinc -isystem /usr/lib/gcc/hppa64-linux-gnu/4.9/include -I/build/linux/linux-4.4.4/arch/parisc/include -Iarch/parisc/include/generated/uapi -Iarch/parisc/include/generated -I/build/linux/linux-4.4.4/include -Iinclude -I/build/linux/linux-4.4.4/arch/parisc/include/uapi -Iarch/parisc/include/generated/uapi -I/build/linux/linux-4.4.4/include/uapi -Iinclude/generated/uapi -include /build/linux/linux-4.4.4/include/linux/kconfig.h -I/build/linux/linux-4.4.4/block -Iblock -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -pipe -mno-space-regs -mdisable-fpregs -ffunction-sections -march=2.0 -mschedule=8000 -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO -fno-cse-follow-jumps -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(blk_merge_part)" -D"KBUILD_MODNAME=KBUILD_STR(blk_merge_part)" -c -o block/.tmp_blk-merge_part.o /build/linux/linux-4.4.4/block/blk-merge_part.c