-
Notifications
You must be signed in to change notification settings - Fork 22
Not supported instr: <MCInst 237 <MCOperand Reg:42>> (LLVM-85) #43
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
Comments
Ran into this as well with your branch. Tried a few things to see if I could figure out what was going on, with no success:
The bisect was unfortunately unhelpful, as rust's history between versions isn't linear; the 1.48.0 and 1.49.0 tags don't have much in common wrt commit history, so the bisect wasn't able to come up with anything conclusive. Best it could do ended with:
Nothing really stood out to me as interesting in the diff between those revisions, but admittedly I'm a rank amateur here, so it's very possible I missed something. Here's the (somewhat janky) script I used with |
I've done A little more analysis of the llvm ir. The issue arises when optimizations are enabled. # works
llc -filetype=obj core-e40c46572e76fe97.core.7bmkbcle-cgu.0.rcgu.ll -O0
# fails
llc -filetype=obj core-e40c46572e76fe97.core.7bmkbcle-cgu.0.rcgu.ll -O1 Fortunately, that last command tells us some more info, namely that the offending function is LLVM ERROR: Not supported instr: <MCInst 237 <MCOperand Reg:42>>
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc -filetype=obj core-e40c46572e76fe97.core.7bmkbcle-cgu.0.rcgu.ll -O1
1. Running pass 'Function Pass Manager' on module 'core-e40c46572e76fe97.core.7bmkbcle-cgu.0.rcgu.ll'.
2. Running pass 'Xtensa Assembly Printer' on function '@_ZN4core3num6bignum5tests6Big8x310mul_digits17hbefc9cd21174a3deE'
#0 0x0000556c3886ff3a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x2243f3a)
#1 0x0000556c3886de04 llvm::sys::RunSignalHandlers() (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x2241e04)
#2 0x0000556c3886df48 SignalHandler(int) (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x2241f48)
#3 0x00007fc863e3cc10 __restore_rt (/lib64/libpthread.so.0+0x12c10)
#4 0x00007fc8638a4de1 raise (/lib64/libc.so.6+0x38de1)
#5 0x00007fc86388e536 abort (/lib64/libc.so.6+0x22536)
#6 0x0000556c387e9756 llvm::report_fatal_error(llvm::Twine const&, bool) (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x21bd756)
#7 0x0000556c387e98ae (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x21bd8ae)
#8 0x0000556c37963105 (anonymous namespace)::XtensaMCCodeEmitter::encodeInstruction(llvm::MCInst const&, llvm::raw_ostream&, llvm::SmallVectorImpl<llvm::MCFixup>&, llvm::MCSubtargetInfo const&) const (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x1337105)
#9 0x0000556c381efd65 llvm::MCELFStreamer::emitInstToData(llvm::MCInst const&, llvm::MCSubtargetInfo const&) (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x1bc3d65)
#10 0x0000556c382050da llvm::MCObjectStreamer::emitInstructionImpl(llvm::MCInst const&, llvm::MCSubtargetInfo const&) (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x1bd90da)
#11 0x0000556c382052b3 llvm::MCObjectStreamer::emitInstruction(llvm::MCInst const&, llvm::MCSubtargetInfo const&) (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x1bd92b3)
#12 0x0000556c377afce5 llvm::XtensaAsmPrinter::emitInstruction(llvm::MachineInstr const*) (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x1183ce5)
#13 0x0000556c37b77871 llvm::AsmPrinter::emitFunctionBody() (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x154b871)
#14 0x0000556c37413795 llvm::AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0xde7795)
#15 0x0000556c37d76e14 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x174ae14)
#16 0x0000556c381288c0 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x1afc8c0)
#17 0x0000556c38129e91 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x1afde91)
#18 0x0000556c38127b08 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x1afbb08)
#19 0x0000556c36c0ab8b compileModule(char**, llvm::LLVMContext&) (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x5deb8b)
#20 0x0000556c36b7ff6e main (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x553f6e)
#21 0x00007fc86388fe6b __libc_start_main (/lib64/libc.so.6+0x23e6b)
#22 0x0000556c36c0434a _start (/home/mabez/development/rust/xtensa/rust-xtensa-dev/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x5d834a)
[1] 30229 abort -filetype=obj core-e40c46572e76fe97.core.7bmkbcle-cgu.0.rcgu.ll -O1 Here's the ASM for the offending function, I didn't immediately spot anything out of place: # -- Begin function _ZN4core3num6bignum5tests6Big8x310mul_digits17hbefc9cd21174a3deE
.literal .LCPI292_0, .Lalloc23096
.literal .LCPI292_1, _ZN4core9panicking18panic_bounds_check17h5d2bbbfe824db14cE
.literal .LCPI292_2, 65280
.literal .LCPI292_3, _ZN4core5slice5index24slice_end_index_len_fail17h7f5b2f0bae923e3cE
.global _ZN4core3num6bignum5tests6Big8x310mul_digits17hbefc9cd21174a3deE
.p2align 2
.type _ZN4core3num6bignum5tests6Big8x310mul_digits17hbefc9cd21174a3deE,@function
_ZN4core3num6bignum5tests6Big8x310mul_digits17hbefc9cd21174a3deE: # @_ZN4core3num6bignum5tests6Big8x310mul_digits17hbefc9cd21174a3deE
# %bb.0: # %start
entry a1, 64
mov.n a15, a3
movi.n a12, 0
s8i a12, a1, 30
s16i a12, a1, 28
l32i.n a10, a2, 0
bltui a10, 4, .LBB292_1
j .LBB292_47
.LBB292_1: # %_ZN4core3num6bignum5tests6Big8x36digits17ha50374386d43ca1eE.exit
addi.n a11, a2, 4
bltu a10, a4, .LBB292_2
j .LBB292_19
.LBB292_2: # %bb3
add.n a8, a15, a4
s32i.n a8, a1, 24
add.n a9, a10, a2
addi.n a10, a9, 5
addi.n a8, a4, 1
s32i.n a8, a1, 0
movi.n a3, 0
sub a12, a10, a11
mov.n a14, a3
mov.n a7, a3
.LBB292_3: # %bb4.i
# =>This Loop Header: Depth=1
# Child Loop BB292_11 Depth 2
mov.n a6, a7
addi.n a9, a12, -1
beqz a9, .LBB292_44
# %bb.4: # %"_ZN99_$LT$core..iter..adapters..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h2f37eb4952fb7497E.exit31.i"
# in Loop: Header=BB292_3 Depth=1
l8ui a5, a11, 0
addi.n a7, a6, 1
addi.n a11, a11, 1
beqz a5, .LBB292_3
# %bb.5: # %"_ZN99_$LT$core..iter..adapters..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h2f37eb4952fb7497E.exit.lr.ph.i"
# in Loop: Header=BB292_3 Depth=1
s32i.n a10, a1, 8
movi.n a10, 3
sub a9, a10, a6
s32i.n a4, a1, 12
s32i.n a12, a1, 4
bltu a10, a9, .LBB292_7
# %bb.6: # %"_ZN99_$LT$core..iter..adapters..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h2f37eb4952fb7497E.exit.lr.ph.i"
# in Loop: Header=BB292_3 Depth=1
mov.n a10, a3
j .LBB292_8
.LBB292_7: # in Loop: Header=BB292_3 Depth=1
movi.n a10, 1
.LBB292_8: # %"_ZN99_$LT$core..iter..adapters..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h2f37eb4952fb7497E.exit.lr.ph.i"
# in Loop: Header=BB292_3 Depth=1
s32i.n a14, a1, 16
s32i.n a2, a1, 20
mov.n a12, a3
bne a10, a3, .LBB292_10
# %bb.9: # %"_ZN99_$LT$core..iter..adapters..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h2f37eb4952fb7497E.exit.lr.ph.i"
# in Loop: Header=BB292_3 Depth=1
mov.n a12, a9
.LBB292_10: # %"_ZN99_$LT$core..iter..adapters..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h2f37eb4952fb7497E.exit.lr.ph.i"
# in Loop: Header=BB292_3 Depth=1
addi.n a13, a12, 1
mov.n a14, a3
mov.n a2, a3
mov.n a9, a3
mov.n a3, a15
.LBB292_11: # %"_ZN99_$LT$core..iter..adapters..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h2f37eb4952fb7497E.exit.i"
# Parent Loop BB292_3 Depth=1
# => This Inner Loop Header: Depth=2
add.n a10, a9, a6
addi.n a13, a13, -1
beqz a13, .LBB292_45
# %bb.12: # %bb19.i
# in Loop: Header=BB292_11 Depth=2
addi.n a4, a3, 1
movi a12, 255
and a14, a14, a12
addi a8, a1, 28
add.n a8, a8, a10
l8ui a10, a8, 0
add.n a10, a10, a14
l8ui a14, a3, 0
mull a14, a14, a5
add.n a10, a10, a14
s8i a10, a8, 0
l32r a8, .LCPI292_2
and a8, a10, a8
srli a14, a8, 8
addi.n a9, a9, 1
mov.n a3, a4
l32i.n a8, a1, 24
bne a4, a8, .LBB292_11
# %bb.13: # %bb14.bb16_crit_edge.i
# in Loop: Header=BB292_3 Depth=1
and a10, a14, a12
l32i.n a4, a1, 12
mov.n a9, a4
mov.n a3, a2
l32i.n a12, a1, 4
beqz a10, .LBB292_16
# %bb.14: # %bb23.i
# in Loop: Header=BB292_3 Depth=1
add.n a10, a6, a4
movi.n a8, 2
bgeu a8, a10, .LBB292_15
j .LBB292_45
.LBB292_15: # %bb24.i
# in Loop: Header=BB292_3 Depth=1
addi a8, a1, 28
add.n a8, a8, a10
s8i a14, a8, 0
l32i.n a9, a1, 0
.LBB292_16: # %bb25.i
# in Loop: Header=BB292_3 Depth=1
add.n a9, a9, a6
l32i.n a8, a1, 16
bltu a8, a9, .LBB292_18
# %bb.17: # %bb25.i
# in Loop: Header=BB292_3 Depth=1
mov.n a9, a8
.LBB292_18: # %bb25.i
# in Loop: Header=BB292_3 Depth=1
l32i.n a10, a1, 8
sub a8, a10, a11
mov.n a14, a9
l32i.n a2, a1, 20
!loopinit a8
.LBB292_19: # %bb2
beqz a10, .LBB292_37
# %bb.20:
add.n a8, a2, a10
addi.n a8, a8, 4
s32i.n a8, a1, 24
addi.n a8, a10, 1
s32i.n a8, a1, 8
add.n a9, a4, a15
mov.n a14, a12
.LBB292_21: # %bb4.outer.i27
# =>This Loop Header: Depth=1
# Child Loop BB292_22 Depth 2
# Child Loop BB292_29 Depth 2
sub a8, a9, a15
addi.n a8, a8, 1
.LBB292_22: # %bb4.i31
# Parent Loop BB292_21 Depth=1
# => This Inner Loop Header: Depth=2
mov.n a7, a12
addi.n a8, a8, -1
beqz a8, .LBB292_44
# %bb.23: # %"_ZN99_$LT$core..iter..adapters..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h2f37eb4952fb7497E.exit31.i34"
# in Loop: Header=BB292_22 Depth=2
l8ui a6, a15, 0
addi.n a12, a7, 1
addi.n a15, a15, 1
beqz a6, .LBB292_22
# %bb.24: # %"_ZN99_$LT$core..iter..adapters..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h2f37eb4952fb7497E.exit.lr.ph.i37"
# in Loop: Header=BB292_21 Depth=1
s32i.n a9, a1, 12
movi.n a9, 3
sub a8, a9, a7
movi.n a5, 0
s32i.n a2, a1, 20
s32i.n a14, a1, 16
bltu a9, a8, .LBB292_26
# %bb.25: # %"_ZN99_$LT$core..iter..adapters..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h2f37eb4952fb7497E.exit.lr.ph.i37"
# in Loop: Header=BB292_21 Depth=1
mov.n a9, a5
mov.n a14, a5
beq a9, a5, .LBB292_27
j .LBB292_28
.LBB292_26: # in Loop: Header=BB292_21 Depth=1
movi.n a9, 1
mov.n a14, a5
bne a9, a5, .LBB292_28
.LBB292_27: # %"_ZN99_$LT$core..iter..adapters..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h2f37eb4952fb7497E.exit.lr.ph.i37"
# in Loop: Header=BB292_21 Depth=1
mov.n a14, a8
.LBB292_28: # %"_ZN99_$LT$core..iter..adapters..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h2f37eb4952fb7497E.exit.lr.ph.i37"
# in Loop: Header=BB292_21 Depth=1
addi.n a4, a14, 1
mov.n a9, a5
mov.n a2, a11
.LBB292_29: # %"_ZN99_$LT$core..iter..adapters..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h2f37eb4952fb7497E.exit.i43"
# Parent Loop BB292_21 Depth=1
# => This Inner Loop Header: Depth=2
add.n a8, a9, a7
addi.n a4, a4, -1
beqz a4, .LBB292_46
# %bb.30: # %bb19.i60
# in Loop: Header=BB292_29 Depth=2
addi.n a3, a2, 1
movi a14, 255
and a5, a5, a14
addi a13, a1, 28
add.n a8, a13, a8
l8ui a13, a8, 0
add.n a13, a13, a5
l8ui a5, a2, 0
mull a5, a5, a6
add.n a13, a13, a5
s8i a13, a8, 0
l32r a8, .LCPI292_2
and a8, a13, a8
srli a5, a8, 8
addi.n a9, a9, 1
mov.n a2, a3
l32i.n a8, a1, 24
bne a3, a8, .LBB292_29
# %bb.31: # %bb14.bb16_crit_edge.i46
# in Loop: Header=BB292_21 Depth=1
and a9, a5, a14
mov.n a8, a10
l32i.n a2, a1, 20
l32i.n a13, a1, 16
beqz a9, .LBB292_34
# %bb.32: # %bb23.i63
# in Loop: Header=BB292_21 Depth=1
add.n a8, a7, a10
movi.n a9, 2
bltu a9, a8, .LBB292_46
# %bb.33: # %bb24.i64
# in Loop: Header=BB292_21 Depth=1
addi a9, a1, 28
add.n a8, a9, a8
s8i a5, a8, 0
l32i.n a8, a1, 8
.LBB292_34: # %bb25.i69
# in Loop: Header=BB292_21 Depth=1
add.n a8, a8, a7
bltu a13, a8, .LBB292_36
# %bb.35: # %bb25.i69
# in Loop: Header=BB292_21 Depth=1
mov.n a8, a13
.LBB292_36: # %bb25.i69
# in Loop: Header=BB292_21 Depth=1
mov.n a14, a8
l32i.n a9, a1, 12
j .LBB292_21
.LBB292_37:
add.n a8, a4, a15
mov.n a14, a12
.LBB292_38: # %bb4.outer.us.i13
# =>This Loop Header: Depth=1
# Child Loop BB292_39 Depth 2
sub a9, a8, a15
addi.n a10, a9, 1
.LBB292_39: # %bb4.us.i23
# Parent Loop BB292_38 Depth=1
# => This Inner Loop Header: Depth=2
mov.n a9, a12
addi.n a10, a10, -1
beqz a10, .LBB292_44
# %bb.40: # %"_ZN99_$LT$core..iter..adapters..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$4next17h2f37eb4952fb7497E.exit31.us.i16"
# in Loop: Header=BB292_39 Depth=2
addi.n a12, a9, 1
addi.n a11, a15, 1
l8ui a13, a15, 0
mov.n a15, a11
beqz a13, .LBB292_39
# %bb.41: # %bb25.us.i19
# in Loop: Header=BB292_38 Depth=1
bltu a14, a9, .LBB292_43
# %bb.42: # %bb25.us.i19
# in Loop: Header=BB292_38 Depth=1
mov.n a9, a14
.LBB292_43: # %bb25.us.i19
# in Loop: Header=BB292_38 Depth=1
mov.n a15, a11
mov.n a14, a9
j .LBB292_38
.LBB292_44: # %bb8
l8ui a8, a1, 30
s8i a8, a2, 6
l8ui a8, a1, 29
s8i a8, a2, 5
l8ui a8, a1, 28
s8i a8, a2, 4
s32i.n a14, a2, 0
retw.n
.LBB292_45: # %panic5.i
movi.n a11, 3
l32r a12, .LCPI292_0
l32r a8, .LCPI292_1
callx8 a8
.LBB292_46: # %panic5.i71
movi.n a11, 3
l32r a12, .LCPI292_0
l32r a9, .LCPI292_1
mov.n a10, a8
callx8 a9
.LBB292_47: # %bb5.i.i.i.i
movi.n a11, 3
l32r a12, .LCPI292_0
l32r a8, .LCPI292_3
callx8 a8
.Lfunc_end292:
.size _ZN4core3num6bignum5tests6Big8x310mul_digits17hbefc9cd21174a3deE, .Lfunc_end292-_ZN4core3num6bignum5tests6Big8x310mul_digits17hbefc9cd21174a3deE
# -- End function Here's the full asm, created by running |
Ah interesting. In my efforts to look into the new work you started, I ended up building a debug version of llvm/rust, and with debug assertions enabled, I get this now:
Interestingly, if I look at that code, the result that triggers the assertion failure is silently ignored when assertions are disabled. My intention here was to build a debug, unoptimized version of |
Figured out the offending commit in LLVM on the I built rust 1.47.0 against the tip of the |
results in a seemingly-functioning rustc; at least rust-xtensa-quickstart now compiles properly.
Please translate that into "issue should remain open (for ....)" or "close issue"
|
Issue should remain open because the bug exists on the tip of the llvm |
I've built a customized rust using 1.50 beta/1.51 nightly and the Espressif xtensa_release_11.0.0, and an updated esp32-hal and it is compiling the Quickstart, for Esp32, with no problems. I am building on Windows 10 using cargo and not Xargo or Xbuild. |
Great spot @kelnos! Awesome work, I've rolled the rust fork back to 9ecb19f esp-rs/rust#44 and rebuilt and it works perfectly! Will merge to the
Does it still work if you build in release? If you're using cargo via |
@andreisfr FYI this is the rust code that causes the error: https://github.com/rust-lang/rust/blob/master/library/core/src/num/bignum.rs#L325 I will try and produce a minimal C example if I have time over the weekend. |
I was using |
Hi @MabezDev, thank you very much for your investigation! It would be very helpful to have an С example which demonstrates the problem to solve it quickly. Thanks also to all for support! |
Here is a small reproducer in IR form: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32"
target triple = "xtensa-none-unknown-elf"
define void @crashing() {
entry:
br i1 undef, label %bb1, label %bb2
bb1:
%a = phi i32 [ 0, %entry ], [ %b, %bb2 ]
unreachable
bb2:
%b = phi i32 [ %c, %bb2 ], [ 1, %entry ]
%c = add i32 %b, 1
%cond = icmp eq i32 %b, 0
br i1 %cond, label %bb1, label %bb2
} Reproduce using:
I don't have a C example, but hopefully this IR will also be enough to fix this bug. Or maybe someone else can try to create a C example based on this IR. |
I managed to get this small IR reproducer using
Normally only |
Hi, @aykevl! Thank you very much for example. Did you observed similar llc's output in example?
|
Yes, this is the crash log I'm getting:
|
I've just been updating the Xtensa Rust fork and I've ran into this issue when building for the esp32 in release mode (haven't yet reproduced on the esp8266).
Here's the llvm IR: core-e40c46572e76fe97.core.7bmkbcle-cgu.0.rcgu.ll.zip
The text was updated successfully, but these errors were encountered: