[LLVMbugs] [Bug 11880] New: Compiler crash on compiling (faulty?) IR

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jan 28 21:39:13 PST 2012


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

             Bug #: 11880
           Summary: Compiler crash on compiling (faulty?) IR
           Product: clang
           Version: 3.0
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: dirkjan at ochtman.nl
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


I've got some code that seems to cause clang to crash. Code:

target triple = "x86_64-apple-darwin11.0.0"

declare i64 @write(i32, i8*, i64)
declare i32 @asprintf(i8**, i8*, ...)

%struct.str = type { i64, i8* }
@str_NL = constant [1 x i8] c"\0a"

define void @print(%struct.str* %str) {
    %1 = getelementptr inbounds %struct.str* %str, i64 0, i32 1
    %2 = load i8** %1
    %3 = getelementptr inbounds %struct.str* %str, i64 0, i32 0
    %4 = load i64* %3
    call i64 @write(i32 1, i8* %2, i64 %4)
    %6 = getelementptr inbounds [1 x i8]* @str_NL, i64 0, i64 0
    call i64 @write(i32 1, i8* %6, i64 1)
    ret void
}

define %struct.str* @str(i64 %n) {
    %1 = alloca %struct.str
    %2 = getelementptr inbounds %struct.str %1, i32 1
    %3 = call i32 (i8**, i8*, ...)* @asprintf(%2, [2 x i8] "%d", i64 %n)
    %4 = getelementptr inbounds %struct.str %1, i32 0
    store i32 %3, i64* %4
    ret %struct.str* %1
}

@str0_data = constant [4 x i8] c"test"
@str0 = internal constant %struct.str { i64 4, i8* getelementptr([4 x i8]*
@str0_data, i32 0, i32 0) }, align 8

define i32 @main(i32 %argc, i8** %argv) nounwind ssp {
    call void @print(%struct.str* @str0)
    ret i32 0
}

I was just working on the @str function, so there's probably something silly in
there. Here's further diagnostic info as spit out by clang:

0  clang             0x0000000109359c52
llvm::SmallVectorImpl<llvm_regmatch_t>::resize(unsigned int) + 1650
1  clang             0x000000010935a0e9
llvm::SmallVectorImpl<llvm_regmatch_t>::resize(unsigned int) + 2825
2  libsystem_c.dylib 0x00007fff9117dcfa _sigtramp + 26
3  libsystem_c.dylib 0x00007fff67e1fd20 _sigtramp + 18446744073018155072
4  clang             0x0000000108273f74
clang::TextDiagnosticBuffer::~TextDiagnosticBuffer() + 3300
5  clang             0x00000001089e8248
clang::PartialDiagnostic::Storage::~Storage() + 5256
6  clang             0x00000001089e3ea2
clang::PragmaNamespace::getIfNamespace() + 18402
7  clang             0x000000010840c2e1
llvm::DenseMap<llvm::ValueMapCallbackVH<llvm::Value const*,
llvm::TrackingVH<llvm::Value>, llvm::ValueMapConfig<llvm::Value const*>,
llvm::DenseMapInfo<llvm::TrackingVH<llvm::Value> > >,
llvm::TrackingVH<llvm::Value>,
llvm::DenseMapInfo<llvm::ValueMapCallbackVH<llvm::Value const*,
llvm::TrackingVH<llvm::Value>, llvm::ValueMapConfig<llvm::Value const*>,
llvm::DenseMapInfo<llvm::TrackingVH<llvm::Value> > > >,
llvm::DenseMapInfo<llvm::TrackingVH<llvm::Value> >
>::erase(llvm::ValueMapCallbackVH<llvm::Value const*,
llvm::TrackingVH<llvm::Value>, llvm::ValueMapConfig<llvm::Value const*>,
llvm::DenseMapInfo<llvm::TrackingVH<llvm::Value> > > const&) + 3249
8  clang             0x0000000108240b0b llvm::DenseMap<clang::IdentifierInfo
const*, unsigned int, llvm::DenseMapInfo<clang::IdentifierInfo const*>,
llvm::DenseMapInfo<unsigned int> >::grow(unsigned int) + 13115
9  clang             0x000000010822d024 llvm::SmallVectorImpl<char
const*>::insert(char const**, char const* const&) + 3348
10 clang             0x000000010822590c
11 clang             0x0000000108229628
llvm::PrettyStackTraceProgram::~PrettyStackTraceProgram() + 760
12 clang             0x0000000108224434
13 clang             0x0000000000000026
Stack dump:
0.    Program arguments: /Users/djc/src/clang/bin/clang -cc1 -triple
x86_64-apple-macosx10.7.2 -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name hello.lng.ll -pic-level 1
-mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2
-target-linker-version 128 -resource-dir
/Users/djc/src/clang/bin/../lib/clang/3.0 -ferror-limit 19 -fmessage-length 100
-stack-protector 1 -fblocks -fobjc-runtime-has-arc -fobjc-runtime-has-weak
-fobjc-dispatch-method=mixed -fdiagnostics-show-option -fcolor-diagnostics -o
/var/folders/kx/r0q_5lzx0jj0v8rkt8xq1qd40000gn/T/hello-tzCsPL.o -x ir
tests/hello.lng.ll

-- 
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