Skip to content

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

Closed
@whitequark

Description

@whitequark

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions