[llvm-bugs] [Bug 24397] New: GVN crashes on the following example

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 7 17:48:43 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24397

            Bug ID: 24397
           Summary: GVN crashes on the following example
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: michael.v.zolotukhin at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Test case:
----------------------
; RUN: opt -basicaa -gvn -march arm64 < %s | FileCheck %s
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"

%struct.A = type { [30 x %struct.B*] }
%struct.B = type {  %struct.B* }

@A = external global %struct.A, align 8
@B = external global [50 x %struct.B], align 8

; CHECK-LABEL: @foo
; CHECK: ret void
define void @foo()  {
entry:
  br  label %BB1

entry2:
  br  label %BB2

BB1:
  %idxprom = load i64, i64* undef, align 1
  %arrayidx = getelementptr inbounds %struct.A, %struct.A* @A, i64 0, i32 0,
i64 %idxprom
  %p = load %struct.B*, %struct.B** %arrayidx, align 8
  %cmpnull = icmp eq %struct.B* %p, null
  br i1 %cmpnull, label %BB2, label %exit

BB2:
  %bc = bitcast %struct.B** %arrayidx to i64*
  %load = load i64, i64* %bc, align 8
  store i64 %load, i64* bitcast (%struct.B** getelementptr inbounds ([50 x
%struct.B], [50 x %struct.B]* @B, i64 0, i64 35, i32 0) to i64*), align 8
  br label %exit

exit:
  ret void
}
----------------------

Stack trace:
$ opt -basicaa -gvn < r.ll -march arm64 -S
Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"),
function cast, file
/Users/buildslave/devel/llvm.git/include/llvm/Support/Casting.h, line 237.
0  opt                      0x000000010c85cafe
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 46
...
9  opt                      0x000000010b2f94ec
llvm::cast_retty<llvm::Instruction, llvm::Value*>::ret_type
llvm::cast<llvm::Instruction, llvm::Value>(llvm::Value*) + 108
10 opt                      0x000000010b979f6d
llvm::PHITransAddr::InsertPHITranslatedSubExpr(llvm::Value*, llvm::BasicBlock*,
llvm::BasicBlock*, llvm::DominatorTree const&,
llvm::SmallVectorImpl<llvm::Instruction*>&) + 237
11 opt                      0x000000010b97a224
llvm::PHITransAddr::InsertPHITranslatedSubExpr(llvm::Value*, llvm::BasicBlock*,
llvm::BasicBlock*, llvm::DominatorTree const&,
llvm::SmallVectorImpl<llvm::Instruction*>&) + 932
12 opt                      0x000000010b97a01b
llvm::PHITransAddr::InsertPHITranslatedSubExpr(llvm::Value*, llvm::BasicBlock*,
llvm::BasicBlock*, llvm::DominatorTree const&,
llvm::SmallVectorImpl<llvm::Instruction*>&) + 411
13 opt                      0x000000010b979e06
llvm::PHITransAddr::PHITranslateWithInsertion(llvm::BasicBlock*,
llvm::BasicBlock*, llvm::DominatorTree const&,
llvm::SmallVectorImpl<llvm::Instruction*>&) + 86
14 opt                      0x000000010c5703fe (anonymous
namespace)::GVN::PerformLoadPRE(llvm::LoadInst*, llvm::SmallVector<(anonymous
namespace)::AvailableValueInBlock, 64u>&, llvm::SmallVector<llvm::BasicBlock*,
64u>&) + 2654
15 opt                      0x000000010c56e80e (anonymous
namespace)::GVN::processNonLocalLoad(llvm::LoadInst*) + 1390
16 opt                      0x000000010c56ac8f (anonymous
namespace)::GVN::processLoad(llvm::LoadInst*) + 1551

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150808/93a3c8c4/attachment.html>


More information about the llvm-bugs mailing list