Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

ExpandStructRegs: Assertion `New->getType() == getType() && "replaceAllUses of value with new value of different type!"' failed. #176

Closed
@TimNN

Description

@TimNN

While working upgrading rust to LLVM 4.0 (rust-lang/rust#40123) I encountered some code being miss-compiled. I investigated this some more recently and found that llc actually produces an assertion when those are enabled.

Compile the following with debug assertions enabled using llc -O0 foo.ll to reproduce:

; ModuleID = 'bugpoint-reduced-simplified.bc'
source_filename = "bugpoint-output-7eb0c3b.bc"
target datalayout = "e-p:32:32-i64:64-v128:32:128-n32-S128"
target triple = "asmjs-unknown-emscripten"

%WrappedArray = type { [2 x i64] }

define fastcc void @_read_wrapped_array(%WrappedArray*) {
entry-block:
  %1 = load %WrappedArray, %WrappedArray* %0, align 8
  %2 = extractvalue %WrappedArray %1, 0
  %.elt = extractvalue [2 x i64] %2, 0
  ret void
}

Output:

llc: .../clang/fastcomp/src/lib/IR/Value.cpp:375: void llvm::Value::doRAUW(llvm::Value*, bool): Assertion `New->getType() == getType() && "replaceAllUses of value with new value of different type!"' failed.
Stack dump:
0.	Program arguments: llc -O0 bugp.1.ll
1.	Running pass 'Function Pass Manager' on module 'bugp.1.ll'.
2.	Running pass 'Expand out variables with struct types' on function '@_read_wrapped_array'

Backtrace from gdb:

#3  0x00007ffff6931c62 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6

#4  0x0000555556a05b08 in llvm::Value::doRAUW (this=0x5555586971a8, New=0x555558693b18, NoMetadata=false)
    at .../src/lib/IR/Value.cpp:374

#5  0x0000555556a05c66 in llvm::Value::replaceAllUsesWith (this=0x5555586971a8, New=0x555558693b18)
    at .../src/lib/IR/Value.cpp:402

#6  0x0000555556f50d65 in ExpandExtractValue (EV=0x5555586971a8, ToErase=0x7fffffffd6d0)
    at .../src/lib/Target/JSBackend/NaCl/ExpandStructRegs.cpp:468

#7  0x0000555556f50efb in ExpandExtractValues (Func=..., Finalize=false)
    at .../src/lib/Target/JSBackend/NaCl/ExpandStructRegs.cpp:485

#8  0x0000555556f5145c in (anonymous namespace)::ExpandStructRegs::runOnFunction (this=0x5555586a47c0, Func=...)
    at .../src/lib/Target/JSBackend/NaCl/ExpandStructRegs.cpp:557

#9  0x0000555556994e30 in llvm::FPPassManager::runOnFunction (this=0x5555586a4880, F=...)
    at .../src/lib/IR/LegacyPassManager.cpp:1513

#10 0x0000555556994fc9 in llvm::FPPassManager::runOnModule (this=0x5555586a4880, M=...)
    at .../src/lib/IR/LegacyPassManager.cpp:1534

#11 0x0000555556995344 in (anonymous namespace)::MPPassManager::runOnModule (this=0x55555868fb60, M=...)
    at .../src/lib/IR/LegacyPassManager.cpp:1590

#12 0x0000555556995a5b in llvm::legacy::PassManagerImpl::run (this=0x5555586a0c70, M=...)
    at .../src/lib/IR/LegacyPassManager.cpp:1693

#13 0x0000555556995c53 in llvm::legacy::PassManager::run (this=0x7fffffffdb10, M=...)
    at .../src/lib/IR/LegacyPassManager.cpp:1724

#14 0x0000555555dc3a16 in compileModule (argv=0x7fffffffe238, Context=...) at .../src/tools/llc/llc.cpp:528

#15 0x0000555555dc2054 in main (argc=3, argv=0x7fffffffe238) at .../src/tools/llc/llc.cpp:285

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