CTSRD-CHERI/llvm

Crash when compiling mips64 PIC code with -mxgot

arichardson opened this issue · 4 comments


BB#0: derived from LLVM BB %entry
    Live Ins: %T9_64
        %vreg8<def> = LUi64 <ga:@fde_mixed_encoding_compare>[TF=13]; GPR64:%vreg8
        %vreg9<def> = DADDu %vreg8, %T9_64; GPR64:%vreg9,%vreg8
        %vreg0<def> = DADDiu %vreg9, <ga:@fde_mixed_encoding_compare>[TF=14]; GPR64:%vreg0,%vreg9
        ADJCALLSTACKDOWN 0, %SP<imp-def,dead>, %SP<imp-use>
        %vreg1<def> = LUi64 <ga:@get_cie_encoding>[TF=22]; GPR64:%vreg1
        %vreg2<def> = DADDu %vreg1<kill>, %vreg0; GPR64:%vreg2,%vreg1,%vreg0
        %vreg3<def> = LD %vreg2, <ga:@get_cie_encoding>[TF=23]; mem:LD8[GlobalValueCallEntry] GPR64:%vreg3,%vreg2
        JALR64Pseudo %vreg3<kill>, <regmask %FP %GP %RA %D12 %D13 %D14 %D15 %F24 %F25 %F26 %F27 %F28 %F29 %F30 %F31 %FP_64 %F_HI24 %F_HI25 %F_HI26 %F_HI27 %F_HI28 %F_HI29 %F_HI30 %F_HI31 %GP_64 %RA_64 %S0 %S1 %S2 %S3 %S4 %S5 %S6 %S7 %D24_64 %D25_64 %D26_64 %D27_64 %D28_64 %D29_64 %D30_64 %D31_64 %S0_64 %S1_64 %S2_64 %S3_64 %S4_64 %S5_64 %S6_64 %S7_64>, %SP<imp-def>, %V0<imp-def>, ...; GPR64:%vreg3
        ADJCALLSTACKUP 0, 0, %SP<imp-def,dead>, %SP<imp-use>
        %vreg4<def> = COPY %V0; GPR32:%vreg4
        ADJCALLSTACKDOWN 0, %SP<imp-def,dead>, %SP<imp-use>
        %vreg5<def> = LD %vreg2, <ga:@get_cie_encoding>[TF=23]; mem:LD8[GlobalValueCallEntry] GPR64:%vreg5,%vreg2
        JALR64Pseudo %vreg5<kill>, <regmask %FP %GP %RA %D12 %D13 %D14 %D15 %F24 %F25 %F26 %F27 %F28 %F29 %F30 %F31 %FP_64 %F_HI24 %F_HI25 %F_HI26 %F_HI27 %F_HI28 %F_HI29 %F_HI30 %F_HI31 %GP_64 %RA_64 %S0 %S1 %S2 %S3 %S4 %S5 %S6 %S7 %D24_64 %D25_64 %D26_64 %D27_64 %D28_64 %D29_64 %D30_64 %D31_64 %S0_64 %S1_64 %S2_64 %S3_64 %S4_64 %S5_64 %S6_64 %S7_64>, %SP<imp-def>, %V0<imp-def>, ...; GPR64:%vreg5
        ADJCALLSTACKUP 0, 0, %SP<imp-def,dead>, %SP<imp-use>
        %vreg6<def> = COPY %V0; GPR32:%vreg6
        %vreg7<def> = ADDiu %ZERO, 0; GPR32:%vreg7
        %V0<def> = COPY %vreg7; GPR32:%vreg7
        RetRA %V0<imp-use>

# End machine code for function fde_mixed_encoding_compare.

UNREACHABLE executed at /local/scratch/alr48/cheri/llvm/lib/Target/Mips/MipsOptimizePICCall.cpp:161!
#0 0x00007f0da115f6f9 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /local/scratch/alr48/cheri/llvm/lib/Support/Unix/Signals.inc:398:11
#1 0x00007f0da115f8a9 PrintStackTraceSignalHandler(void*) /local/scratch/alr48/cheri/llvm/lib/Support/Unix/Signals.inc:494:1
#2 0x00007f0da115df33 llvm::sys::RunSignalHandlers() /local/scratch/alr48/cheri/llvm/lib/Support/Signals.cpp:0:5
#3 0x00007f0da115fc04 SignalHandler(int) /local/scratch/alr48/cheri/llvm/lib/Support/Unix/Signals.inc:252:1
#4 0x00007f0da06b8390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#5 0x00007f0d9fa71428 gsignal /build/glibc-9tT8Do/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#6 0x00007f0d9fa7302a abort /build/glibc-9tT8Do/glibc-2.23/stdlib/abort.c:91:0
#7 0x00007f0da107e8d0 LLVMInstallFatalErrorHandler /local/scratch/alr48/cheri/llvm/lib/Support/ErrorHandling.cpp:138:0
#8 0x00007f0da530800d eraseGPOpnd(llvm::MachineInstr&) /local/scratch/alr48/cheri/llvm/lib/Target/Mips/MipsOptimizePICCall.cpp:162:1
#9 0x00007f0da530763e (anonymous namespace)::OptimizePICCall::visitNode((anonymous namespace)::MBBInfo&) /local/scratch/alr48/cheri/llvm/lib/Target/Mips/MipsOptimizePICCall.cpp:0:7
#10 0x00007f0da5307275 (anonymous namespace)::OptimizePICCall::runOnMachineFunction(llvm::MachineFunction&) /local/scratch/alr48/cheri/llvm/lib/Target/Mips/MipsOptimizePICCall.cpp:202:16
#11 0x00007f0da2c4a5e1 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /local/scratch/alr48/cheri/llvm/lib/CodeGen/MachineFunctionPass.cpp:62:8
#12 0x00007f0da245b33f llvm::FPPassManager::runOnFunction(llvm::Function&) /local/scratch/alr48/cheri/llvm/lib/IR/LegacyPassManager.cpp:1514:27
#13 0x00007f0da245b655 llvm::FPPassManager::runOnModule(llvm::Module&) /local/scratch/alr48/cheri/llvm/lib/IR/LegacyPassManager.cpp:1536:16
#14 0x00007f0da245bdea (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /local/scratch/alr48/cheri/llvm/lib/IR/LegacyPassManager.cpp:1592:27
#15 0x00007f0da245b916 llvm::legacy::PassManagerImpl::run(llvm::Module&) /local/scratch/alr48/cheri/llvm/lib/IR/LegacyPassManager.cpp:1695:16
#16 0x00007f0da245c301 llvm::legacy::PassManager::run(llvm::Module&) /local/scratch/alr48/cheri/llvm/lib/IR/LegacyPassManager.cpp:1726:3
#17 0x0000000000235347 compileModule(char**, llvm::LLVMContext&) /local/scratch/alr48/cheri/llvm/tools/llc/llc.cpp:585:42
#18 0x0000000000233704 main /local/scratch/alr48/cheri/llvm/tools/llc/llc.cpp:336:13
#19 0x00007f0d9fa5c830 __libc_start_main /build/glibc-9tT8Do/glibc-2.23/csu/../csu/libc-start.c:325:0
#20 0x0000000000233029 _start (/local/scratch/alr48/cheri/build/llvm-debug-build/./bin/llc+0x233029)
Stack dump:
0.      Program arguments: /local/scratch/alr48/cheri/build/llvm-debug-build/./bin/llc -mtriple=mips64-unknown-freebsd -relocation-model=pic -mcpu=mips64r2 -O0 -mxgot /local/scratch/alr48/cheri/llvm/test/CodeGen/Mips/mips-optimize-pic-calls-crash.ll -print-after-all -filetype=asm -o - 
1.      Running pass 'Function Pass Manager' on module '/local/scratch/alr48/cheri/llvm/test/CodeGen/Mips/mips-optimize-pic-calls-crash.ll'.
2.      Running pass 'Mips OptimizePICCall' on function '@fde_mixed_encoding_compare'

This test does not crash with upstream LLVM. The intiial machine BB looks a bit different:

# *** IR Dump After Expand ISel Pseudo-instructions ***:
# Machine code for function fde_mixed_encoding_compare: IsSSA, TracksLiveness
Function Live Ins: %T9_64

BB#0: derived from LLVM BB %entry
    Live Ins: %T9_64
        %vreg6<def> = LUi64 <ga:@fde_mixed_encoding_compare>[TF=13]; GPR64:%vreg6
        %vreg7<def> = DADDu %vreg6, %T9_64; GPR64:%vreg7,%vreg6
        %vreg0<def> = DADDiu %vreg7, <ga:@fde_mixed_encoding_compare>[TF=14]; GPR64:%vreg0,%vreg7
        ADJCALLSTACKDOWN 0, %SP<imp-def,dead>, %SP<imp-use>
        %vreg1<def> = LD %vreg0, <ga:@get_cie_encoding>[TF=16]; mem:LD8[GOT] GPR64:%vreg1,%vreg0
        %vreg2<def> = DADDiu %vreg1<kill>, <ga:@get_cie_encoding>[TF=17]; GPR64:%vreg2,%vreg1
        JALR64Pseudo %vreg2, <regmask %FP %GP %RA %D12 %D13 %D14 %D15 %F24 %F25 %F26 %F27 %F28 %F29 %F30 %F31 %FP_64 %F_HI24 %F_HI25 %F_HI26 %F_HI27 %F_HI28 %F_HI29 %F_HI30 %F_HI31 %GP_64 %RA_64 %S0 %S1 %S2 %S3 %S4 %S5 %S6 %S7 %D24_64 %D25_64 %D26_64 %D27_64 %D28_64 %D29_64 %D30_64 %D31_64 %S0_64 %S1_64 %S2_64 %S3_64 %S4_64 %S5_64 %S6_64 %S7_64>, %SP<imp-def>, %V0<imp-def>, ...; GPR64:%vreg2
        ADJCALLSTACKUP 0, 0, %SP<imp-def,dead>, %SP<imp-use>
        %vreg3<def> = COPY %V0; GPR32:%vreg3
        ADJCALLSTACKDOWN 0, %SP<imp-def,dead>, %SP<imp-use>
        JALR64Pseudo %vreg2, <regmask %FP %GP %RA %D12 %D13 %D14 %D15 %F24 %F25 %F26 %F27 %F28 %F29 %F30 %F31 %FP_64 %F_HI24 %F_HI25 %F_HI26 %F_HI27 %F_HI28 %F_HI29 %F_HI30 %F_HI31 %GP_64 %RA_64 %S0 %S1 %S2 %S3 %S4 %S5 %S6 %S7 %D24_64 %D25_64 %D26_64 %D27_64 %D28_64 %D29_64 %D30_64 %D31_64 %S0_64 %S1_64 %S2_64 %S3_64 %S4_64 %S5_64 %S6_64 %S7_64>, %SP<imp-def>, %V0<imp-def>, ...; GPR64:%vreg2
        ADJCALLSTACKUP 0, 0, %SP<imp-def,dead>, %SP<imp-use>
        %vreg4<def> = COPY %V0; GPR32:%vreg4
        %vreg5<def> = ADDiu %ZERO, 0; GPR32:%vreg5
        %V0<def> = COPY %vreg5; GPR32:%vreg5
        RetRA %V0<imp-use>

# End machine code for function fde_mixed_encoding_compare.

Test case?

Marked as XFAIL: bc4455b

Odd - I'm building libunwind for MIPS at -O2 and not seeing any compiler crashes.