LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 18600 - [InstCombine] assert "Value::replaceAllUsesWith(<null>) is invalid!"
Summary: [InstCombine] assert "Value::replaceAllUsesWith(<null>) is invalid!"
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Scalar Optimizations (show other bugs)
Version: 3.3
Hardware: PC Linux
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-24 08:09 PST by Jose Fonseca
Modified: 2014-01-25 09:31 PST (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments
bugpoint-reduced-simplified.ll (2.36 KB, application/octet-stream)
2014-01-24 08:09 PST, Jose Fonseca
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jose Fonseca 2014-01-24 08:09:35 PST
Created attachment 11930 [details]
bugpoint-reduced-simplified.ll

$ gdb --args ~/work/vmware/llvm/llvm/build/linux-x86_64/Debug+Asserts/bin/opt bugpoint-reduced-simplified.ll -instcombine -disable-output
(gdb) r
Starting program: /home/jfonseca/work/vmware/llvm/llvm/build/linux-x86_64/Debug+Asserts/bin/opt bugpoint-reduced-simplified.ll -instcombine -disable-output
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
opt: /home/jfonseca/work/vmware/llvm/llvm/lib/IR/Value.cpp:304: void llvm::Value::replaceAllUsesWith(llvm::Value*): Assertion `New && "Value::replaceAllUsesWith(<null>) is invalid!"' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff6e09f77 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56	../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff6e09f77 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff6e0d5e8 in __GI_abort () at abort.c:90
#2  0x00007ffff6e02d43 in __assert_fail_base (fmt=0x7ffff6f59f58 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x1388e80 "New && \"Value::replaceAllUsesWith(<null>) is invalid!\"", 
    file=file@entry=0x13886c0 "/home/jfonseca/work/vmware/llvm/llvm/lib/IR/Value.cpp", line=line@entry=304, 
    function=function@entry=0x138ae00 <llvm::Value::replaceAllUsesWith(llvm::Value*)::__PRETTY_FUNCTION__> "void llvm::Value::replaceAllUsesWith(llvm::Value*)") at assert.c:92
#3  0x00007ffff6e02df2 in __GI___assert_fail (assertion=0x1388e80 "New && \"Value::replaceAllUsesWith(<null>) is invalid!\"", 
    file=0x13886c0 "/home/jfonseca/work/vmware/llvm/llvm/lib/IR/Value.cpp", line=304, 
    function=0x138ae00 <llvm::Value::replaceAllUsesWith(llvm::Value*)::__PRETTY_FUNCTION__> "void llvm::Value::replaceAllUsesWith(llvm::Value*)")
    at assert.c:101
#4  0x0000000000ed99ab in llvm::Value::replaceAllUsesWith (this=this@entry=0x1772590, New=New@entry=0x0)
    at /home/jfonseca/work/vmware/llvm/llvm/lib/IR/Value.cpp:304
#5  0x0000000000aef2dc in llvm::InstCombiner::ReplaceInstUsesWith (this=<optimised out>, I=..., V=0x0)
    at /home/jfonseca/work/vmware/llvm/llvm/lib/Transforms/InstCombine/InstCombine.h:278
#6  0x0000000000b4ddf0 in llvm::InstCombiner::visitExtractElementInst (this=0x1782370, EI=...)
    at /home/jfonseca/work/vmware/llvm/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp:180
#7  0x0000000000aecd64 in llvm::InstCombiner::DoOneIteration (this=this@entry=0x1782370, F=..., Iteration=Iteration@entry=0)
    at /home/jfonseca/work/vmware/llvm/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:2427
#8  0x0000000000aed958 in llvm::InstCombiner::runOnFunction (this=0x1782370, F=...)
    at /home/jfonseca/work/vmware/llvm/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:2525
#9  0x0000000000ebdf0c in llvm::FPPassManager::runOnFunction (this=this@entry=0x1789090, F=...)
    at /home/jfonseca/work/vmware/llvm/llvm/lib/IR/LegacyPassManager.cpp:1538
#10 0x0000000000ebe35b in llvm::FPPassManager::runOnModule (this=0x1789090, M=...) at /home/jfonseca/work/vmware/llvm/llvm/lib/IR/LegacyPassManager.cpp:1558
#11 0x0000000000ebe6a3 in runOnModule (M=..., this=<optimised out>) at /home/jfonseca/work/vmware/llvm/llvm/lib/IR/LegacyPassManager.cpp:1616
#12 llvm::legacy::PassManagerImpl::run (this=0x176c400, M=...) at /home/jfonseca/work/vmware/llvm/llvm/lib/IR/LegacyPassManager.cpp:1711
#13 0x0000000000ebe8ce in llvm::legacy::PassManager::run (this=this@entry=0x7fffffffd950, M=...)
    at /home/jfonseca/work/vmware/llvm/llvm/lib/IR/LegacyPassManager.cpp:1746
#14 0x000000000052bb63 in main (argc=<optimised out>, argv=0x7fffffffdbc8) at /home/jfonseca/work/vmware/llvm/llvm/tools/opt/opt.cpp:853
(gdb) 

This happens with all versions between LLVM 3.1 and LLVM 3.4

More the the actual crash, what I find surprising is that the complex constants expression is not being folded automatically as it its being built.  This IR was generated by the C bindings, inside llvmpipe Mesa driver.
Comment 1 Benjamin Kramer 2014-01-24 13:03:16 PST
Fixed in r200028.

The expressions don't get folded while building because casting a <16 x i8> to <4 x i8> requires a DataLayout. That's not available to the IRBuilder.
Comment 2 Jose Fonseca 2014-01-25 09:31:58 PST
> Fixed in r200028.

Thanks for the quick turnaround.

> The expressions don't get folded while building because casting a <16 x i8> to <4 x i8> requires a DataLayout. That's not available to the IRBuilder.

Oh, of course: it depends on big/little endianess.

So exactly which of the LLVM optimization passes is the main responsible for folding these?