Skip to content
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

Closed
llvmbot opened this issue Apr 25, 2009 · 9 comments
Closed

[Linux kernel] TargetRegisterInfo::isPhysicalRegister assertion #4436

llvmbot opened this issue Apr 25, 2009 · 9 comments
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 25, 2009

Bugzilla Link 4064
Resolution FIXED
Resolved on Mar 06, 2010 13:59
Version unspecified
OS Linux
Depends On #3751
Blocks llvm/llvm-bugzilla-archive#4068
Attachments bugpoint program output, bugpoint output 2 of 3, bugpoint output 3 of 3, bitcode for original file (pre-bugpoint)
Reporter LLVM Bugzilla Contributor
CC @asl,@edwintorok

Extended Description

After making two changes to the kernel to get it to build with clang,

  1. In kernel's Makefile, scripts/Makefile.lib and scripts/Makefile.host, perform the following substitution:

    s/-Wp,-MD,/-MD -MF /

  2. 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

  1. parser at end of file
  2. Code generation
  3. Running pass 'X86 AT&T-Style Assembly Printer' on function '@start_kernel'
    make[1]: *** [init/main.o] Error 250
    make: *** [init] Error 2
@edwintorok
Copy link
Contributor

this is the offending asm line: %0 = call i64 asm "movq %gs:${1:P},$0", "=r,m,{dirflag},{fpsr},~{flags}"(i64 @​per_cpu__kernel_stack)

Looks like #​3379

@nlewycky
Copy link
Contributor

*** Bug llvm/llvm-bugzilla-archive#4080 has been marked as a duplicate of this bug. ***

@llvmbot
Copy link
Collaborator Author

llvmbot commented Apr 26, 2009

The frequency of this assertion increases dramatically, when building latest upstream kernel (~2.6.30-rc3) rather than 2.6.29.

@edwintorok
Copy link
Contributor

proposed patch
This patch makes the assert go away, and the correct asm is emitted.
However I am not sure if it'll work in all cases, since I can't find the documentation for %P1 in gcc's docs.

@lattner
Copy link
Collaborator

lattner commented Apr 26, 2009

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?

@asl
Copy link
Collaborator

asl commented Apr 28, 2009

Created an attachment (id=2894) [details]
proposed patch

This patch makes the assert go away, and the correct asm is emitted.
However I am not sure if it'll work in all cases, since I can't find the
documentation for %P1 in gcc's docs.
The patch does not work in PIC mode.... I'm working on the fix.

@asl
Copy link
Collaborator

asl commented Apr 28, 2009

@edwintorok
Copy link
Contributor

mentioned in issue llvm/llvm-bugzilla-archive#4068

@nlewycky
Copy link
Contributor

mentioned in issue llvm/llvm-bugzilla-archive#4080

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category
Projects
None yet
Development

No branches or pull requests

5 participants