[LLVMbugs] [Bug 13521] New: [NVPTX] Crash in backend when compiled in release mode

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Aug 2 21:17:38 PDT 2012


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

             Bug #: 13521
           Summary: [NVPTX] Crash in backend when compiled in release mode
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: maemarcus at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


A simple function compilation crashes in release mode, however code generation
for it in debug mode works very well:

Reprocase
=========

> cat crash.ll
target datalayout = "e-p:64:64-i64:64:64-f64:64:64-n1:8:16:32:64"
target triple = "nvptx64-unknown-unknown"

%"struct.kernelgen::kernel_t" = type opaque
%struct.kernelgen_callback_data_t = type opaque

@__kernelgen_memory = external addrspace(1) global i32*
@__kernelgen_callback = external addrspace(1) global i32*

define ptx_device i8* @kernelgen_malloc(i64 %size, i8* %ret) nounwind
alwaysinline {
entry:
  %rem = and i64 %size, 4095
  %tobool = icmp eq i64 %rem, 0
  br i1 %tobool, label %if.end, label %if.then

if.then:                                          ; preds = %entry
  %sub = add i64 %size, 4096
  %add = sub i64 %sub, %rem
  br label %if.end

if.end:                                           ; preds = %if.then, %entry
  %size.addr.0 = phi i64 [ %add, %if.then ], [ %size, %entry ]
  %0 = load i32* addrspace(1)* @__kernelgen_memory, align 8
  %add2 = add i64 %size.addr.0, 4096
  %szpool = getelementptr inbounds i32* %0, i64 2
  %1 = bitcast i32* %szpool to i64*
  %2 = load i64* %1, align 8
  %szused = getelementptr inbounds i32* %0, i64 4
  %3 = bitcast i32* %szused to i64*
  %4 = load i64* %3, align 8
  %count = getelementptr inbounds i32* %0, i64 6
  %5 = bitcast i32* %count to i64*
  %6 = load i64* %5, align 8
  %mul = shl i64 %6, 12
  %add3.neg = sub i64 %2, %4
  %sub4 = sub i64 %add3.neg, %mul
  %cmp = icmp ugt i64 %add2, %sub4
  br i1 %cmp, label %return, label %for.cond.preheader

for.cond.preheader:                               ; preds = %if.end
  br label %for.cond

for.cond:                                         ; preds = %if.end39,
%for.cond.preheader
  %i.0 = phi i64 [ %add42, %if.end39 ], [ 0, %for.cond.preheader ]
  %add8 = add i64 %add2, %i.0
  %cmp10 = icmp ult i64 %add8, %2
  br i1 %cmp10, label %for.body, label %return

for.body:                                         ; preds = %for.cond
  %7 = bitcast i32* %0 to i8**
  %8 = load i8** %7, align 8
  %add.ptr = getelementptr inbounds i8* %8, i64 %i.0
  %is_available = bitcast i8* %add.ptr to i32*
  %9 = load i32* %is_available, align 4
  %cmp11 = icmp eq i32 %9, 0
  %add.ptr.sum1 = add i64 %i.0, 4
  %size13 = getelementptr inbounds i8* %8, i64 %add.ptr.sum1
  br i1 %cmp11, label %if.then12, label %if.end39

if.then12:                                        ; preds = %for.body
  %10 = bitcast i8* %size13 to i32*
  %11 = load i32* %10, align 4
  %cmp14 = icmp eq i32 %11, 0
  br i1 %cmp14, label %if.then15, label %if.end23

if.then15:                                        ; preds = %if.then12
  %12 = bitcast i8* %size13 to i32*
  %13 = bitcast i8* %add.ptr to i32*
  store i32 1, i32* %13, align 4
  %conv = trunc i64 %add2 to i32
  store i32 %conv, i32* %12, align 4
  %sunkaddr = ptrtoint i32* %0 to i64
  %sunkaddr1 = add i64 %sunkaddr, 24
  %sunkaddr2 = inttoptr i64 %sunkaddr1 to i64*
  %14 = load i64* %sunkaddr2, align 8
  %inc = add i64 %14, 1
  store i64 %inc, i64* %sunkaddr2, align 8
  %sunkaddr3 = ptrtoint i32* %0 to i64
  %sunkaddr4 = add i64 %sunkaddr3, 16
  %sunkaddr5 = inttoptr i64 %sunkaddr4 to i64*
  %15 = load i64* %sunkaddr5, align 8
  %add21 = add i64 %15, %size.addr.0
  store i64 %add21, i64* %sunkaddr5, align 8
  %add.ptr.sum3 = add i64 %i.0, 4096
  %add.ptr22 = getelementptr inbounds i8* %8, i64 %add.ptr.sum3
  br label %return

if.end23:                                         ; preds = %if.then12
  %conv25 = sext i32 %11 to i64
  %cmp27 = icmp ult i64 %conv25, %add2
  br i1 %cmp27, label %if.end39, label %if.then28

if.then28:                                        ; preds = %if.end23
  %16 = bitcast i8* %add.ptr to i32*
  store i32 1, i32* %16, align 4
  %sunkaddr6 = ptrtoint i32* %0 to i64
  %sunkaddr7 = add i64 %sunkaddr6, 24
  %sunkaddr8 = inttoptr i64 %sunkaddr7 to i64*
  %17 = load i64* %sunkaddr8, align 8
  %inc34 = add i64 %17, 1
  store i64 %inc34, i64* %sunkaddr8, align 8
  %sunkaddr9 = ptrtoint i32* %0 to i64
  %sunkaddr10 = add i64 %sunkaddr9, 16
  %sunkaddr11 = inttoptr i64 %sunkaddr10 to i64*
  %18 = load i64* %sunkaddr11, align 8
  %sub32 = add i64 %conv25, -4096
  %add36 = add i64 %sub32, %18
  store i64 %add36, i64* %sunkaddr11, align 8
  %add.ptr.sum2 = add i64 %i.0, 4096
  %add.ptr37 = getelementptr inbounds i8* %8, i64 %add.ptr.sum2
  br label %return

if.end39:                                         ; preds = %if.end23,
%for.body
  %19 = bitcast i8* %size13 to i32*
  %20 = load i32* %19, align 4
  %conv41 = sext i32 %20 to i64
  %add42 = add i64 %conv41, %i.0
  br label %for.cond

return:                                           ; preds = %for.cond,
%if.then28, %if.then15, %if.end
  %retval.0 = phi i8* [ %add.ptr22, %if.then15 ], [ %add.ptr37, %if.then28 ], [
null, %if.end ], [ null, %for.cond ]
  ret i8* %retval.0
}

!0 = metadata !{i32 6096, i32 6133}

Crash in backend (only if LLVM compiled with --enable-optimized)
================

> LD_PRELOAD=../install/lib/libLLVM-3.2svn.so ../install/bin/llc -march="nvptx" -mcpu="sm_20" crash.ll -o -
//
// Generated by LLVM NVPTX Back-End
//

.version 3.0
.target sm_20, texmode_independent
.address_size 32

.extern .global .align 4 .b32 __kernelgen_memory;
.extern .global .align 4 .b32 __kernelgen_callback;

llc: /RHM/users/work/dmikushin/llvm/include/llvm/ADT/DenseMap.h:96: void
llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT>::clear() [with DerivedT =
llvm::DenseMap<llvm::MachineBasicBlock*, <unnamed>::BlockChain*,
llvm::DenseMapInfo<llvm::MachineBasicBlock*> >, KeyT =
llvm::MachineBasicBlock*, ValueT = <unnamed>::BlockChain*, KeyInfoT =
llvm::DenseMapInfo<llvm::MachineBasicBlock*>]: Assertion `getNumEntries() == 0
&& "Node count imbalance!"' failed.
0  libLLVM-3.2svn.so 0x00007f6fc1382f3f
1  libLLVM-3.2svn.so 0x00007f6fc1384e5e
2  libpthread.so.0   0x00007f6fc06505d0
3  libc.so.6         0x00007f6fbfebb945 gsignal + 53
4  libc.so.6         0x00007f6fbfebcf21 abort + 385
5  libc.so.6         0x00007f6fbfeb4810 __assert_fail + 240
6  libLLVM-3.2svn.so 0x00007f6fc0cce03a
7  libLLVM-3.2svn.so 0x00007f6fc0ec07cf
llvm::FPPassManager::runOnFunction(llvm::Function&) + 623
8  libLLVM-3.2svn.so 0x00007f6fc0ec0873
llvm::FPPassManager::runOnModule(llvm::Module&) + 51
9  libLLVM-3.2svn.so 0x00007f6fc0ec0314
llvm::MPPassManager::runOnModule(llvm::Module&) + 564
10 libLLVM-3.2svn.so 0x00007f6fc0ec0470
llvm::PassManagerImpl::run(llvm::Module&) + 160
11 llc               0x0000000000409694 main + 4948
12 libc.so.6         0x00007f6fbfea7bc6 __libc_start_main + 230
13 llc               0x0000000000405579
Stack dump:
0.    Program arguments: ../install/bin/llc -march=nvptx -mcpu=sm_20 crash.ll
-o - 
1.    Running pass 'Function Pass Manager' on module 'crash.ll'.
2.    Running pass 'Branch Probability Basic Block Placement' on function
'@kernelgen_malloc'
Aborted

LLVM version info
=================

> cd .. && svn info
Path: .
Working Copy Root Path: /RHM/users/work/dmikushin/llvm
URL: http://llvm.org/svn/llvm-project/llvm/trunk
Repository Root: http://llvm.org/svn/llvm-project
Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8
Revision: 161230
Node Kind: directory
Schedule: normal
Last Changed Author: jush
Last Changed Rev: 161230
Last Changed Date: 2012-08-03 06:37:48 +0400 (Fri, 03 Aug 2012)

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