[LLVMbugs] [Bug 6112] New: llvm-gcc: cast of pointer to constant value fails in llvm BitcodeWriter.cpp: 714

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Jan 22 01:48:40 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=6112

           Summary: llvm-gcc: cast of pointer to constant value fails in
                    llvm BitcodeWriter.cpp: 714
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: compile-fail
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: martijn at martijnrutten.com
                CC: llvmbugs at cs.uiuc.edu


llvm-gcc (cc1) fails when writing bitcode for the test-suite application
MultiSource/Applications/Burg/main.c with -g and optimization > O0 enabled. The
normal testsuite compilation without -g compiles fine.

See the debug trace below. 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:714 "const Constant *C =
cast<Constant>(V);" fails with 'V' being a pointer type which is not a
constant.

How to reproduce:

cd llvm/projects/llvm-test/MultiSource/Applications/Burg
llvm-gcc -c -g -O1 main.c -emit-llvm

llvm-gcc output:

main.c: In function 'main':
main.c:22: warning: return type of 'main' is not 'int'
cc1: /home1/martijn/work/llvm-svn/llvm/include/llvm/Support/Casting.h:199:
typename llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&) [with X =
llvm::Constant, Y = const llvm::Value*]: Assertion `isa<X>(Val) && "cast<Ty>()
argument of incompatible type!"' failed.
main.c: At top level:
main.c:182: internal compiler error: Aborted
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://llvm.org/bugs/> for instructions.

Debug trace:

Starting program:
/home1/martijn/work/llvm-svn/install/libexec/gcc/i686-pc-linux-gnu/4.2.1/cc1
-quiet -iprefix
/home1/martijn/work/llvm-svn/llvm-gcc-obj/gcc/../lib/gcc/i686-pc-linux-gnu/4.2.1/
main.c -emit-llvm-bc -o main.o -quiet -dumpbase main.c -mtune=generic -auxbase
main -g -O1
[Thread debugging using libthread_db enabled]
main.c: In function 'main':
main.c:22: warning: return type of 'main' is not 'int'
cc1: /home1/martijn/work/llvm-svn/llvm/include/llvm/Support/Casting.h:199:
typename llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&) [with X =
llvm::Constant, Y = const llvm::Value*]: Assertion `isa<X>(Val) && "cast<Ty>()
argument of incompatible type!"' failed.

Program received signal SIGABRT, Aborted.
0xb7fe2430 in __kernel_vsyscall ()
(gdb) bt
#0  0xb7fe2430 in __kernel_vsyscall ()
#1  0xb7d614d1 in raise () from /lib/tls/i686/cmov/libc.so.6
#2  0xb7d64932 in abort () from /lib/tls/i686/cmov/libc.so.6
#3  0xb7d5a648 in __assert_fail () from /lib/tls/i686/cmov/libc.so.6
#4  0x08570a9f in llvm::cast_retty<llvm::Constant, llvm::Value
const*>::ret_type llvm::cast<llvm::Constant, llvm::Value const*>(llvm::Value
const* const&)
    ()
#5  0x0856896a in WriteConstants (FirstVal=59, LastVal=176, VE=..., Stream=...,
isGlobal=true)
    at
/home1/martijn/work/llvm-svn/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:714
#6  0x08569e5e in WriteModuleConstants (VE=..., Stream=...) at
/home1/martijn/work/llvm-svn/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:894
#7  0x0856cd81 in WriteModule (M=0x91549c8, Stream=...) at
/home1/martijn/work/llvm-svn/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1474
#8  0x0856d2c1 in llvm::WriteBitcodeToStream (M=0x91549c8, Stream=...) at
/home1/martijn/work/llvm-svn/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1599
#9  0x0856d146 in llvm::WriteBitcodeToFile (M=0x91549c8, Out=...) at
/home1/martijn/work/llvm-svn/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1569
#10 0x08564d5b in runOnModule (this=0x9151e00, M=...) at
/home1/martijn/work/llvm-svn/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp:29
#11 0x08ccb336 in llvm::MPPassManager::runOnModule (this=0x91aa790, M=...) at
/home1/martijn/work/llvm-svn/llvm/lib/VMCore/PassManager.cpp:1409
#12 0x08ccb810 in llvm::PassManagerImpl::run (this=0x91ab278, M=...) at
/home1/martijn/work/llvm-svn/llvm/lib/VMCore/PassManager.cpp:1490
#13 0x08ccbaf5 in llvm::PassManager::run (this=0x916ba68, M=...) at
/home1/martijn/work/llvm-svn/llvm/lib/VMCore/PassManager.cpp:1519
#14 0x083ff2ff in llvm_asm_file_end () at
../../llvm-gcc/gcc/llvm-backend.cpp:955
#15 0x083a8f56 in compile_file (argc=16, argv=0xbffff214) at
../../llvm-gcc/gcc/toplev.c:1193
#16 do_compile (argc=16, argv=0xbffff214) at ../../llvm-gcc/gcc/toplev.c:2269
#17 toplev_main (argc=16, argv=0xbffff214) at ../../llvm-gcc/gcc/toplev.c:2301
#18 0x080e5aa7 in main (argc=16, argv=0xbffff214) at
../../llvm-gcc/gcc/llvm-main.cpp:47
(gdb) f 5
#5  0x0856896a in WriteConstants (FirstVal=59, LastVal=176, VE=..., Stream=...,
isGlobal=true)
    at
/home1/martijn/work/llvm-svn/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:714
714         const Constant *C = cast<Constant>(V);

(gdb) p *V->VTy->Ty
$1 = {<llvm::AbstractTypeUser> = {_vptr.AbstractTypeUser = 0x90764e8}, ID =
llvm::Type::PointerTyID, Abstract = false, SubclassData = 0, RefCount = 0, 
  Context = @0x912ab38, ForwardType = 0x0, AbstractTypeUsers =
{<std::_Vector_base<llvm::AbstractTypeUser*,
std::allocator<llvm::AbstractTypeUser*> >> = {
      _M_impl = {<std::allocator<llvm::AbstractTypeUser*>> =
{<__gnu_cxx::new_allocator<llvm::AbstractTypeUser*>> = {<No data fields>}, <No
data fields>}, 
        _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data
fields>}, NumContainedTys = 1, ContainedTys = 0x9188f30}


Environment:

llvm-gcc revision: r94023
llvm revision: r94077
uname -a: Linux martijn 2.6.31-17-generic-pae #54-Ubuntu SMP Thu Dec 10
17:23:29 UTC 2009 i686 GNU/Linux
gcc --version: gcc (Ubuntu 4.4.1-4ubuntu8) 4.4.1


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list