Skip to content
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

[ARM] LLVM: Unknown addressing mode for CP reference! UNREACHABLE executed at ARMConstantIslandPass.cpp:755 #41672

Closed
whitequark opened this issue May 1, 2017 · 7 comments

Comments

@whitequark
Copy link
Member

whitequark commented May 1, 2017

To reproduce in a real-world example, follow these instructions. Note that the bug is somewhat finicky: it's not exhibited in debug builds, and it's not exhibited also until main crosses a certain threshold size (might be related to inliner, not sure). It also does not crash (or AFAICT miscompile) on non-Asserts LLVM builds, so beware.

Reduced example, crashing LLVM from the current nightly:

; RUN: llc crash.ll
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "thumbv7em-none--eabihf"

@__rustc_debug_gdb_scripts_section__ = internal unnamed_addr constant [34 x i8] c"\01gdb_load_rust_pretty_printers.py\00", section ".debug_gdb_scripts", align 1

define i32 @main(i32, i8** nocapture readnone) {
top:
  %2 = load volatile i8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @__rustc_debug_gdb_scripts_section__, i32 0, i32 0), align 1
  ret i32 0
}

Backtrace:

#2  0x000055555636cbaa in llvm::llvm_unreachable_internal (msg=msg@entry=0x5555567aaec8 "Unknown addressing mode for CP reference!",
    file=file@entry=0x5555567aa908 "/home/whitequark/Work/rust/src/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp", line=line@entry=755)
    at /home/whitequark/Work/rust/src/llvm/lib/Support/ErrorHandling.cpp:118
#3  0x0000555555a5bc48 in (anonymous namespace)::ARMConstantIslands::initializeFunctionInfo (this=this@entry=0x555557402480, CPEMIs=...)
    at /home/whitequark/Work/rust/src/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:755
#4  0x0000555555a5d23d in (anonymous namespace)::ARMConstantIslands::runOnMachineFunction (this=0x555557402480, mf=...)
    at /home/whitequark/Work/rust/src/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:373
#5  0x0000555555dacbd5 in llvm::MachineFunctionPass::runOnFunction (this=0x555557402480, F=...)
    at /home/whitequark/Work/rust/src/llvm/lib/CodeGen/MachineFunctionPass.cpp:62
#6  0x000055555606470b in llvm::FPPassManager::runOnFunction (this=0x5555573e5760, F=...)
    at /home/whitequark/Work/rust/src/llvm/lib/IR/LegacyPassManager.cpp:1510
#7  0x00005555560647c4 in llvm::FPPassManager::runOnModule (this=0x5555573e5760, M=...)
    at /home/whitequark/Work/rust/src/llvm/lib/IR/LegacyPassManager.cpp:1531
#8  0x0000555556065321 in (anonymous namespace)::MPPassManager::runOnModule (M=..., this=<optimized out>)
    at /home/whitequark/Work/rust/src/llvm/lib/IR/LegacyPassManager.cpp:1587
#9  llvm::legacy::PassManagerImpl::run (this=0x5555573dcaf0, M=...) at /home/whitequark/Work/rust/src/llvm/lib/IR/LegacyPassManager.cpp:1690
#10 0x000055555583b349 in compileModule (argv=0x7fffffffdb38, Context=...) at /home/whitequark/Work/rust/src/llvm/tools/llc/llc.cpp:532
#11 0x0000555555804e80 in main (argc=2, argv=0x7fffffffdb38) at /home/whitequark/Work/rust/src/llvm/tools/llc/llc.cpp:289

MC dump:

(gdb) p MF->dump()
# Machine code for function main: NoPHIs, NoVRegs
Constant Pool:
  cp#0: , align=4

BB#0: derived from LLVM BB %top
        %R0<def,dead> = t2LDRBpci <cp#0>, pred:14, pred:%noreg; mem:Volatile LD1[getelementptr inbounds ([34 x i8], [34 x i8]* @__rustc_debug_gdb_scripts_section__, i32 0, i32 0)](dereferenceable)
        %R0<def>, %CPSR<def,dead> = tMOVi8 0, pred:14, pred:%noreg
        tBX_RET pred:14, pred:%noreg, %R0<imp-use,kill>

BB#1: Align 2 (4 bytes)
        CONSTPOOL_ENTRY 0, <cp#0>, 36

# End machine code for function main.

This is actually quite baffling because there's a case for ARM::t2LDRBpci in the crashing switch. Not sure what's up.

@arielb1
Copy link
Contributor

arielb1 commented May 1, 2017

Can you report this bug at bugs.llvm.org?

@whitequark
Copy link
Member Author

@arielb1 haven't reproduced it with ToT LLVM yet (I don't have a build handy). Do you?

@arielb1
Copy link
Contributor

arielb1 commented May 1, 2017

I have a "somewhere between 4 and 5" LLVM and it compiles with it. OTOH, it also compiles with the LLVM in build/llvm - maybe I'm missing something Yup I was using an LLVM without debug assertions.

@arielb1
Copy link
Contributor

arielb1 commented May 1, 2017

Looking around, this looks like https://bugs.llvm.org/show_bug.cgi?id=31997 which is fixed on trunk.

@whitequark
Copy link
Member Author

Can someone cherry-pick r295964 into rustc's LLVM?

@arielb1
Copy link
Contributor

arielb1 commented May 1, 2017

You can do it yourself - open a PR against https://github.com/rust-lang/llvm

@whitequark
Copy link
Member Author

See rust-lang/llvm#76.

bors added a commit that referenced this issue May 4, 2017
Update llvm to pull in various backports

Fixes #41672
Fixes #41630
Fixes #41685
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants