Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Cannot select: X86ISD::CALL ICE with -mx32 -O2 -fno-plt #35716

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR36743
Status NEW
Importance P normal
Reported by Steven Noonan (steven@uplinklabs.net)
Reported on 2018-03-14 11:58:28 -0700
Last modified on 2020-11-29 13:30:10 -0800
Version 6.0
Hardware PC Linux
CC glaubitz@physik.fu-berlin.de, harald@gigawatt.nl, llvm-bugs@lists.llvm.org, llvm-dev@ndave.org, llvm-dev@redking.me.uk
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also PR34268
A straightforward reduced test case:

==> /tmp/testcase-cc8b84.c <==
# 1 "<built-in>"
# 1 "testcase.c"
main() { a(); }

==> /tmp/testcase-cc8b84.sh <==
# Crash reproducer for clang version 6.0.0 (tags/RELEASE_600/final)
# Driver args: "-v" "-O2" "-fno-plt" "-mx32" "-c" "testcase.c"
# Original command:  "/usr/bin/clang-6.0" "-cc1" "-triple" "x86_64-pc-linux-
gnux32" "-emit-obj" "-disable-free" "-disable-llvm-verifier" "-discard-value-
names" "-main-file-name" "testcase.c" "-mrelocation-model" "pic" "-pic-level"
"2" "-pic-is-pie" "-mthread-model" "posix" "-fmath-errno" "-masm-verbose" "-
mconstructor-aliases" "-fno-plt" "-munwind-tables" "-fuse-init-array" "-target-
cpu" "x86-64" "-dwarf-column-info" "-debugger-tuning=gdb" "-momit-leaf-frame-
pointer" "-v" "-coverage-notes-file" "/home/steven/Development/ec2-
packages/libc++/testcase.gcno" "-resource-dir" "/usr/lib/clang/6.0.0" "-
internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/clang/6.0.0/include" "-internal-externc-isystem" "/include" "-
internal-externc-isystem" "/usr/include" "-O2" "-fdebug-compilation-dir"
"/home/steven/Development/ec2-packages/libc++" "-ferror-limit" "19" "-fmessage-
length" "190" "-stack-protector" "2" "-fobjc-runtime=gcc" "-fdiagnostics-show-
option" "-fcolor-diagnostics" "-vectorize-loops" "-vectorize-slp" "-o"
"testcase.o" "-x" "c" "testcase.c"
 "/usr/bin/clang-6.0" "-cc1" "-triple" "x86_64-pc-linux-gnux32" "-emit-obj" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "testcase.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mthread-model" "posix" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-fno-plt" "-munwind-tables" "-fuse-init-array" "-target-cpu" "x86-64" "-dwarf-column-info" "-debugger-tuning=gdb" "-momit-leaf-frame-pointer" "-v" "-coverage-notes-file" "/home/steven/Development/ec2-packages/libc++/testcase.gcno" "-O2" "-ferror-limit" "19" "-fmessage-length" "190" "-stack-protector" "2" "-fobjc-runtime=gcc" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-vectorize-loops" "-vectorize-slp" "-x" "c" "testcase-cc8b84.c"

Attempting to compile with clang 6.0 with "-fno-plt -mx32" at any optimization
level higher than -O0 will break at isel. This problem exists in both 6.0 and
trunk:

$ /usr/bin/clang -v -O2 -fno-plt -mx32 -c testcase.c
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnux32
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/5.5.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/6.4.1
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/7.3.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/5.5.0
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/6.4.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-
gnu/7.3.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/6.4.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.4.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.3.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: x32;@mx32
Found CUDA installation: /opt/cuda, version 9.1
 "/usr/bin/clang-6.0" -cc1 -triple x86_64-pc-linux-gnux32 -emit-obj -disable-free -disable-llvm-verifier -discard-value-names -main-file-name testcase.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -fno-plt -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -v -coverage-notes-file /home/steven/Development/ec2-packages/libc++/testcase.gcno -resource-dir /usr/lib/clang/6.0.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib/clang/6.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir /home/steven/Development/ec2-packages/libc++ -ferror-limit 19 -fmessage-length 190 -stack-protector 2 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o testcase.o -x c testcase.c
clang -cc1 version 6.0.0 based upon LLVM 6.0.0 default target x86_64-pc-linux-
gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/clang/6.0.0/include
 /usr/include
End of search list.
testcase.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-
int]
main() { a(); }
^
testcase.c:1:10: warning: implicit declaration of function 'a' is invalid in
C99 [-Wimplicit-function-declaration]
main() { a(); }
         ^
fatal error: error in backend: Cannot select: 0x2e382f8: ch,glue = X86ISD::CALL
0x2e38088, 0x2e38228, Register:i8 %al, RegisterMask:Untyped, 0x2e38088:1
  0x2e38228: i32,ch = load<LD4[GOT]> 0x2d819b0, 0x2e38158, undef:i32
    0x2e38158: i32 = X86ISD::WrapperRIP TargetGlobalAddress:i32<i32 (...)* @a> 0 [TF=5]
      0x2e380f0: i32 = TargetGlobalAddress<i32 (...)* @a> 0 [TF=5]
    0x2e381c0: i32 = undef
  0x2e38020: i8 = Register %al
  0x2e38290: Untyped = RegisterMask
  0x2e38088: ch,glue = CopyToReg 0x2e37f50, Register:i8 %al, Constant:i8<0>
    0x2e38020: i8 = Register %al
    0x2e37fb8: i8 = Constant<0>
In function: main
clang-6.0: error: clang frontend command failed with exit code 70 (use -v to
see invocation)
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnux32
Thread model: posix
InstalledDir: /usr/bin
Quuxplusone commented 6 years ago

Potentially related to http://llvm.org/PR34268 per comment there. If so this could be (part of) blocking use of LLVM JIT on x32 for PostgreSQL per discussion in https://www.postgresql-archive.org/patch-Support-LLVM-7-td6037827.html