Skip to content

[Linux kernel] TargetRegisterInfo::isPhysicalRegister assertion #4436

Closed
@llvmbot

Description

@llvmbot
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclangClang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions