llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.62k stars 11.83k forks source link

[PowerPC] Assertion failed: `!DeadOrKillToUnset && "Shouldn't kill same register twice"' #44719

Closed vchuravy closed 4 years ago

vchuravy commented 4 years ago
Bugzilla Link 45374
Resolution FIXED
Resolved on Apr 09, 2020 20:20
Version 10.0
OS Linux
CC @ecnelises,@nemanjai
Fixed by commit(s) 7f3787c0f2746f7748d642ffc9ce699a295df9e4

Extended Description

Stacktrace:

removeRedundantLIs at /home/vchuravy/julia/deps/srccache/llvm-10.0.0/lib/Target/PowerPC/PPCPreEmitPeephole.cpp:113
runOnMachineFunction at /home/vchuravy/julia/deps/srccache/llvm-10.0.0/lib/Target/PowerPC/PPCPreEmitPeephole.cpp:184
runOnFunction at /home/vchuravy/julia/deps/srccache/llvm-10.0.0/lib/CodeGen/MachineFunctionPass.cpp:73
runOnFunction at /home/vchuravy/julia/deps/srccache/llvm-10.0.0/lib/IR/LegacyPassManager.cpp:1481
runOnModule at /home/vchuravy/julia/deps/srccache/llvm-10.0.0/lib/IR/LegacyPassManager.cpp:1517
runOnModule at /home/vchuravy/julia/deps/srccache/llvm-10.0.0/lib/IR/LegacyPassManager.cpp:1582
run at /home/vchuravy/julia/deps/srccache/llvm-10.0.0/lib/IR/LegacyPassManager.cpp:1694
run at /home/vchuravy/julia/deps/srccache/llvm-10.0.0/lib/IR/LegacyPassManager.cpp:1725
operator() at /home/vchuravy/julia/src/aotcompile.cpp:509
jl_dump_native at /home/vchuravy/julia/src/aotcompile.cpp:518
(gdb) p MBB.dump()                                                                                                                                 
bb.14.SP_return:
; predecessors: %bb.13
  liveins: $x3
  renamable $x3 = LDtocL @​jl_false, killed renamable $x3, implicit $x2 :: (load 8 from got)
  renamable $x3 = LD 0, killed renamable $x3 :: (dereferenceable load 8 from @​jl_false, !tbaa !​11669)
  dead $r4 = LI 130, implicit-def $x4, debug-location !​29895; /nobackup/users/vchuravy/builds/julia-dbg-10/usr/share/julia/stdlib/v1.5/Pkg/src/REP$
Mode/completions.jl:104
  $x1 = ADDI8 $x1, 240, debug-location !​29895; /nobackup/users/vchuravy/builds/julia-dbg-10/usr/share/julia/stdlib/v1.5/Pkg/src/REPLMode/completio$
s.jl:104
  $x0 = LD 16, $x1, debug-location !​29895; /nobackup/users/vchuravy/builds/julia-dbg-10/usr/share/julia/stdlib/v1.5/Pkg/src/REPLMode/completions.j$
:104
  $x30 = LD -16, $x1, debug-location !​29895 :: (load 8 from %fixed-stack.0, align 16); /nobackup/users/vchuravy/builds/julia-dbg-10/usr/share/juli$
/stdlib/v1.5/Pkg/src/REPLMode/completions.jl:104
  $x29 = LD -24, $x1, debug-location !​29895 :: (load 8 from %fixed-stack.1); /nobackup/users/vchuravy/builds/julia-dbg-10/usr/share/julia/stdlib/v$
.5/Pkg/src/REPLMode/completions.jl:104
  $x28 = LD -32, $x1, debug-location !​29895 :: (load 8 from %fixed-stack.2, align 16); /nobackup/users/vchuravy/builds/julia-dbg-10/usr/share/juli$
/stdlib/v1.5/Pkg/src/REPLMode/completions.jl:104
  MTLR8 killed $x0, implicit-def $lr8, debug-location !​29895; /nobackup/users/vchuravy/builds/julia-dbg-10/usr/share/julia/stdlib/v1.5/Pkg/src/REP$
Mode/completions.jl:104
  $x27 = LD -40, $x1, debug-location !​29895 :: (load 8 from %fixed-stack.3); /nobackup/users/vchuravy/builds/julia-dbg-10/usr/share/julia/stdlib/v$
.5/Pkg/src/REPLMode/completions.jl:104
  $x26 = LD -48, $x1, debug-location !​29895 :: (load 8 from %fixed-stack.4, align 16); /nobackup/users/vchuravy/builds/julia-dbg-10/usr/share/juli$
/stdlib/v1.5/Pkg/src/REPLMode/completions.jl:104
  $x25 = LD -56, $x1, debug-location !​29895 :: (load 8 from %fixed-stack.5); /nobackup/users/vchuravy/builds/julia-dbg-10/usr/share/julia/stdlib/v$
.5/Pkg/src/REPLMode/completions.jl:104
  BLR8 implicit $lr8, implicit $rm, implicit killed $x3, implicit killed $x4, debug-location !​29895; /nobackup/users/vchuravy/builds/julia-dbg-10/u
sr/share/julia/stdlib/v1.5/Pkg/src/REPLMode/completions.jl:104
111               int KillIdx = AfterBBI->findRegisterUseOperandIdx(Reg, true, TRI);
112               if (KillIdx != -1) {
113                 assert(!DeadOrKillToUnset && "Shouldn't kill same register twice");
114                 DeadOrKillToUnset = &AfterBBI->getOperand(KillIdx);
115                 LLVM_DEBUG(dbgs()
116                            << " Kill flag of " << *DeadOrKillToUnset << " from "
117                            << *AfterBBI << " is a unsetting candidate\n");
(gdb) p AfterBBI->dump()
  BLR8 implicit $lr8, implicit $rm, implicit killed $x3, implicit killed $x4, debug-location !&#8203;29895; /nobackup/users/vchuravy/builds/julia-dbg-10/usr/share/julia/stdlib/v1.5/Pkg/src/REPLMode/completions.jl:104

This is the same configuration as llvm/llvm-project#44711

nemanjai commented 4 years ago

Pushed a fix in 7f3787c0f2746f7748d642ffc9ce699a295df9e4. Please verify and if it solves the problem, close the bug.

vchuravy commented 4 years ago

How did you get the mir file?

Allow me to give you some context. Julia compiles a huge set of functions into a single shared-library that is loaded at startup and is called the system-image. Normally to reproduce these issues it is enough to dump the post-optimized LLVM IR and then run llc over it. That method of reproduction failed and there most be a subtle difference how either the TargetMachine is configured or the pipeline is invoked.

So to produce the reproducer I manually extracted the MIR in GDB with:

`` b /home/vchuravy/julia/deps/srccache/llvm-10.0.0/lib/Target/PowerPC/PPCPreEmitPeephole.cpp:179

commands

call printMIR(dbgs(), MF) cont end

and then added the LLVM IR manually after stripping metadata. I can give you the bitcode file that I thought should reproduce it with llc, but doesn't or I can try and dump the entire module with printMIR before running PPCPreEmitPeephole.

llvmbot commented 4 years ago

Created attachment 23322 [details] Reprdocuer

Not yet fully minimal, but at least a standalone reproducer using MIR as an input: usr/tools/llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-unknown -run-pass ppc-pre-emit-peephole ~/func.mir

I had to strip the metadata since I couldn't cleanly exfiltrate that.

How did you get the mir file? I use below command to get the func.mir, but it's different from yours llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-unknown -stop-before=ppc-pre-emit-peephole -o stop-before.mir func.ll

If you can give me the func.ll and tell me the option to get the func.mir, I can narrow the case and it's convenient to find the bug.

llvmbot commented 4 years ago

Thanks. I can reproduce this error, I will investigate it.

vchuravy commented 4 years ago

Reprdocuer Not yet fully minimal, but at least a standalone reproducer using MIR as an input: usr/tools/llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-unknown -run-pass ppc-pre-emit-peephole ~/func.mir

I had to strip the metadata since I couldn't cleanly exfiltrate that.

vchuravy commented 4 years ago

Trying to do that it's a bit challenging since this is triggered from within Julia and my attempts at reproduction outside so far have failed.

llvmbot commented 4 years ago

@​Valentin Churavy , could you give the error case and the command line you used? So someone can reproduce it easily.