-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Linux kernel] TargetRegisterInfo::isPhysicalRegister assertion #4436
Comments
this is the offending asm line: %0 = call i64 asm "movq %gs:${1:P},$0", "=r,m, Looks like #3379 |
*** Bug llvm/llvm-bugzilla-archive#4080 has been marked as a duplicate of this bug. *** |
The frequency of this assertion increases dramatically, when building latest upstream kernel (~2.6.30-rc3) rather than 2.6.29. |
proposed patch |
The definition of P is: P -- if PIC, print an @PLT suffix. (this is above print_operand in gcc/config/i386/i386.c). The patch looks ok to me as a start, but should check to see if in PIC mode or not I guess. Also, why the +3? |
|
I hope this should fix it: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090427/076811.html |
mentioned in issue llvm/llvm-bugzilla-archive#4068 |
mentioned in issue llvm/llvm-bugzilla-archive#4080 |
Extended Description
After making two changes to the kernel to get it to build with clang,
In kernel's Makefile, scripts/Makefile.lib and scripts/Makefile.host, perform the following substitution:
s/-Wp,-MD,/-MD -MF /
In include/linux/kernel.h, force macro THIS_IP to return zero, rather than using label. (Older kernels may not require this step)
clang successfully begins the build process, making it to one of the first actual kernel files, init/main.c, where it crashes (shown below).
I ran bugpoint, and have attached the output.
clang -MD -MF init/.main.o.d -nostdinc -isystem include -Iinclude -I/spare/repo/linux-2.6/arch/x86/include -include include/linux/autoconf.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -O2 -m64 -march=core2 -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wframe-larger-than=2048 -fno-stack-protector -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -Wdeclaration-after-statement -Wno-pointer-sign -fwrapv -fno-dwarf2-cfi-asm -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(main)" -D"KBUILD_MODNAME=KBUILD_STR(main)" -c -o init/main.o init/main.c
clang: warning: the clang compiler does not yet support '-pg'
warning: unknown warning option: -Wframe-larger-than=2048
init/main.c:570:9: warning: format string is not a string literal (potentially insecure) [-Wformat-nonliteral]
printk(linux_banner);
^~~~~~~~~~~~
init/main.c:628:9: warning: format string is not a string literal (potentially insecure) [-Wformat-nonliteral]
panic(panic_later, panic_param);
^~~~~~~~~~~
clang-cc: /garz/repo/llvm/include/llvm/Target/TargetRegisterInfo.h:301: static bool llvm::TargetRegisterInfo::isPhysicalRegister(unsigned int): Assertion `Reg && "this is not a register!"' failed.
0 clang-cc 0x000000000103677f
1 clang-cc 0x0000000001036b69
2 libpthread.so.0 0x00000034c020f0f0
3 libc.so.6 0x00000034bf632f05 gsignal + 53
4 libc.so.6 0x00000034bf634a73 abort + 387
5 libc.so.6 0x00000034bf62bef9 __assert_fail + 233
6 clang-cc 0x0000000000a45532
7 clang-cc 0x0000000000a4721e
8 clang-cc 0x0000000000d1a410
9 clang-cc 0x0000000000a4619b
10 clang-cc 0x0000000000a46b0e
11 clang-cc 0x0000000000fd2b49
12 clang-cc 0x0000000000fd352e
13 clang-cc 0x0000000000fd373b
14 clang-cc 0x00000000004386e5
15 clang-cc 0x0000000000438b17
16 clang-cc 0x00000000005a431d
17 clang-cc 0x0000000000474c56
18 clang-cc 0x000000000047c0e1 main + 1953
19 libc.so.6 0x00000034bf61e576 libc_start_main + 230
20 clang-cc 0x00000000004287e9
Stack dump:
0. Program arguments: /usr/local/bin/../libexec/clang-cc -triple x86_64-unknown-linux-gnu -S -disable-free -main-file-name main.c --relocation-model static --disable-fp-elim --unwind-tables=1 --disable-red-zone --mattr -mmx,-sse,-sse2,-3dnow --fmath-errno=1 -nostdinc -dependency-file init/.main.o.d -MT init/main.o -sys-header-deps -isystem include -include include/linux/autoconf.h -D__KERNEL -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DKBUILD_STR(s)=#s -DKBUILD_BASENAME=KBUILD_STR(main) -DKBUILD_MODNAME=KBUILD_STR(main) -Iinclude -I/spare/repo/linux-2.6/arch/x86/include -O2 -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -Werror-implicit-function-declaration -Wno-sign-compare -Wframe-larger-than=2048 -Wdeclaration-after-statement -Wno-pointer-sign -fno-common -fdiagnostics-show-option -o /tmp/cc-ZU4Nhi.s -x c init/main.c
make[1]: *** [init/main.o] Error 250
make: *** [init] Error 2
The text was updated successfully, but these errors were encountered: