[LLVMbugs] [Bug 11489] New: opt -gvn: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Dec 6 03:29:32 PST 2011


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

             Bug #: 11489
           Summary: opt -gvn: Assertion `isa<X>(Val) && "cast<Ty>()
                    argument of incompatible type!
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Global Analyses
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: eugeni.stepanov at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


# opt -gvn 1.ll -o 1.bc

opt: clang_src/include/llvm/Support/Casting.h:194: typename
llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&) [with X =
llvm::Instruction, Y = llvm::User*]: Assertion `isa<X>(Val) && "cast<Ty>()
argument of incompatible type!"' failed.
0  opt             0x0000000000900e0f
1  opt             0x0000000000903082
2  libpthread.so.0 0x00007f4143b068f0
3  libc.so.6       0x00007f4142df5a75 gsignal + 53
4  libc.so.6       0x00007f4142df95c0 abort + 384
5  libc.so.6       0x00007f4142dee941 __assert_fail + 241
6  opt             0x00000000007044dd
llvm::MemoryDependenceAnalysis::getModRefInfo(llvm::Instruction const*,
llvm::AliasAnalysis::Location const&) + 2605
7  opt             0x0000000000704686
llvm::MemoryDependenceAnalysis::getPointerDependencyFrom(llvm::AliasAnalysis::Location
const&, bool, llvm::ilist_iterator<llvm::Instruction>, llvm::BasicBlock*) + 230
8  opt             0x0000000000704c17
llvm::MemoryDependenceAnalysis::GetNonLocalInfoForBlock(llvm::AliasAnalysis::Location
const&, bool, llvm::BasicBlock*, std::vector<llvm::NonLocalDepEntry,
std::allocator<llvm::NonLocalDepEntry> >*, unsigned int) + 231
9  opt             0x00000000007063c0
llvm::MemoryDependenceAnalysis::getNonLocalPointerDepFromBB(llvm::PHITransAddr
const&, llvm::AliasAnalysis::Location const&, bool, llvm::BasicBlock*,
llvm::SmallVectorImpl<llvm::NonLocalDepResult>&,
llvm::DenseMap<llvm::BasicBlock*, llvm::Value*,
llvm::DenseMapInfo<llvm::BasicBlock*>, llvm::DenseMapInfo<llvm::Value*> >&,
bool) + 3520
10 opt             0x0000000000707996
llvm::MemoryDependenceAnalysis::getNonLocalPointerDependency(llvm::AliasAnalysis::Location
const&, bool, llvm::BasicBlock*,
llvm::SmallVectorImpl<llvm::NonLocalDepResult>&) + 246
11 opt             0x00000000005215d0
12 opt             0x0000000000523639
13 opt             0x00000000005243d8
14 opt             0x0000000000524d8b
15 opt             0x00000000008a471b
llvm::FPPassManager::runOnFunction(llvm::Function&) + 587
16 opt             0x00000000008a4803
llvm::FPPassManager::runOnModule(llvm::Module&) + 51
17 opt             0x00000000008a41e7
llvm::MPPassManager::runOnModule(llvm::Module&) + 503
18 opt             0x00000000008a437b llvm::PassManagerImpl::run(llvm::Module&)
+ 187
19 opt             0x00000000004c5d8d main + 4797
20 libc.so.6       0x00007f4142de0c4d __libc_start_main + 253
21 opt             0x00000000004b9c59
Stack dump:
0.    Program arguments: ./opt -gvn 1.ll -o 1.bc 
1.    Running pass 'Function Pass Manager' on module '1.ll'.
2.    Running pass 'Global Value Numbering' on function '@g'
Aborted


# cat 1.ll

; ModuleID = '1.c'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define void @g() nounwind uwtable {
entry:
  %code = alloca i8*, align 8
  store i8* bitcast (void (...)* @f to i8*), i8** %code, align 8
  %0 = load i8** %code, align 8
  %arrayidx = getelementptr inbounds i8* %0, i64 0
  %1 = load i8* %arrayidx
  %tobool = icmp ne i8 %1, 0
  br i1 %tobool, label %if.then, label %if.end

if.then:                                          ; preds = %entry
  call void (...)* @gg()
  br label %if.end

if.end:                                           ; preds = %if.then, %entry
  %2 = load i8** %code, align 8
  %3 = load i8* %2
  call void @hh(i8 zeroext %3)
  ret void
}

declare void @f(...)

declare void @gg(...)

declare void @hh(i8 zeroext)


# This can also be reproduced with clang -c -O2 1.c
# cat 1.c

void gg();
void hh(unsigned char);
void f();

void g() {
  unsigned char *code    = (unsigned char*)f;
  if (code[0]) {
    gg();
  }
  hh(*code);
}

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