[LLVMdev] [LLVMDev]: UNREACHABLE executed!

Justin Holewinski justin.holewinski at gmail.com
Wed Nov 2 05:03:10 PDT 2011


On Nov 2, 2011 6:31 AM, "Semion Prihodko" <semion.ababo at gmail.com> wrote:
>
> Hi, guys!
>
> I write a virtual machine which uses LLVM as back-end code generator. The
following function code causes strange "UNREACHABLE executed!" error:
>
> define void @p1(%1*) {
>   %2 = call i8* @llvm.stacksave()
>   %3 = alloca %0
>   %4 = getelementptr %0* %3, i64 1
>   %5 = ptrtoint %0* %3 to i64
>   %6 = ptrtoint %0* %4 to i64
>   %7 = sub i64 %6, %5
>   %8 = bitcast %0* %3 to i8*
>   call void @llvm.memset.p0i8.i64(i8* %8, i8 0, i64 %7, i32 0, i1 false)
>   %9 = bitcast %1* %0 to [8 x i8]*
>   %10 = bitcast %0* %3 to [8 x i8]*
>   %11 = load [8 x i8]* %9
>   store [8 x i8] %11, [8 x i8]* %10
>   %12 = call i8* @llvm.stacksave()
>   %13 = alloca %0
>   %14 = getelementptr %0* %13, i64 1
>   %15 = ptrtoint %0* %13 to i64
>   %16 = ptrtoint %0* %14 to i64
>   %17 = sub i64 %16, %15
>   %18 = bitcast %0* %13 to i8*
>   call void @llvm.memset.p0i8.i64(i8* %18, i8 0, i64 %17, i32 0, i1 false)
>   %19 = getelementptr %1* %0, i64 0, i32 0, i32 8
>   %20 = bitcast i8* %19 to [8 x i8]*
>   %21 = bitcast %0* %13 to [8 x i8]*
>   %22 = load [8 x i8]* %20
>   store [8 x i8] %22, [8 x i8]* %21
>   %23 = bitcast %0* %13 to i64*
>   %24 = bitcast %0* %3 to i64*
>   %25 = load i64* %23
>   %26 = load i64* %24
>   %27 = icmp sgt i64 %25, %26
>   br i1 %27, label %29, label %28
>
> ; <label>:28                                      ; preds = %1
>   ret void
>
> ; <label>:29                                      ; preds = %1
>   %30 = call i8* @llvm.stacksave()
>   %31 = alloca %0*
>   store %0* zeroinitializer, %0** %31
>   %32 = getelementptr %1* %0, i64 0, i32 0, i32 0
>   %33 = bitcast i8* %32 to %0**
>   %34 = load %0** %33
>   %35 = ptrtoint %0* %34 to i64
>   %36 = icmp ne i64 %35, 0
>   br i1 %36, label %37, label %42
>
> ; <label>:37                                      ; preds = %29
>   %38 = bitcast %0* %34 to i64*
>   %39 = getelementptr i64* %38, i32 -1
>   %40 = load i64* %39
>   %41 = add i64 %40, 1
>   store i64 %41, i64* %39
>   br label %42
>
> ; <label>:42                                      ; preds = %37, %29
>   %43 = load %0** %31
>   %44 = ptrtoint %0* %43 to i64
>   %45 = icmp ne i64 %44, 0
>   br i1 %45, label %46, label %52
>
> ; <label>:46                                      ; preds = %42
>   %47 = bitcast %0* %43 to i64*
>   %48 = getelementptr i64* %47, i32 -1
>   %49 = load i64* %48
>   %50 = sub i64 %49, 1
>   store i64 %50, i64* %48
>   %51 = icmp ne i64 %50, 0
>   br i1 %51, label %70, label %52
>
> ; <label>:52                                      ; preds = %70, %46, %42
>   store %0* %34, %0** %31
>   %53 = call i8* @llvm.stacksave()
>   %54 = alloca %1
>   %55 = getelementptr %1* %54, i64 1
>   %56 = ptrtoint %1* %54 to i64
>   %57 = ptrtoint %1* %55 to i64
>   %58 = sub i64 %57, %56
>   %59 = bitcast %1* %54 to i8*
>   call void @llvm.memset.p0i8.i64(i8* %59, i8 0, i64 %58, i32 0, i1 false)
>   %60 = bitcast %0* %3 to [8 x i8]*
>   %61 = bitcast %1* %54 to [8 x i8]*
>   %62 = load [8 x i8]* %60
>   store [8 x i8] %62, [8 x i8]* %61
>   %63 = bitcast %0* %13 to [8 x i8]*
>   %64 = getelementptr %1* %54, i64 0, i32 0, i32 8
>   %65 = bitcast i8* %64 to [8 x i8]*
>   %66 = load [8 x i8]* %63
>   store [8 x i8] %66, [8 x i8]* %65
>   %67 = load %0** %31
>   %68 = ptrtoint %0* %67 to i64
>   %69 = icmp ne i64 %68, 0
>   br i1 %69, label %72, label %77
>
> ; <label>:70                                      ; preds = %46
>   %71 = bitcast %0* %43 to i8*
>   call void @destroy(i8* inttoptr (i64 161025200 to i8*), i8* inttoptr
(i64 161028240 to i8*), i8* %71)
>   br label %52
>
> ; <label>:72                                      ; preds = %52
>   %73 = bitcast %0* %67 to i64*
>   %74 = getelementptr i64* %73, i32 -1
>   %75 = load i64* %74
>   %76 = add i64 %75, 1
>   store i64 %76, i64* %74
>   br label %77
>
> ; <label>:77                                      ; preds = %72, %52
>   %78 = getelementptr %1* %54, i64 0, i32 0, i32 0
>   %79 = bitcast i8* %78 to %0**
>   %80 = load %0** %79
>   %81 = ptrtoint %0* %80 to i64
>   %82 = icmp ne i64 %81, 0
>   br i1 %82, label %83, label %89
>
> ; <label>:83                                      ; preds = %77
>   %84 = bitcast %0* %80 to i64*
>   %85 = getelementptr i64* %84, i32 -1
>   %86 = load i64* %85
>   %87 = sub i64 %86, 1
>   store i64 %87, i64* %85
>   %88 = icmp ne i64 %87, 0
>   br i1 %88, label %109, label %89
>
> ; <label>:89                                      ; preds = %109, %83, %77
>   store %0* %67, %0** %79
>   call void @p0(%1* %54)
>   %90 = bitcast %1* %54 to [8 x i8]*
>   %91 = bitcast %0* %13 to [8 x i8]*
>   %92 = load [8 x i8]* %90
>   store [8 x i8] %92, [8 x i8]* %91
>   %93 = bitcast %1* %54 to i64*
>   %94 = load i64* %93
>   %95 = add i64 %94, 1
>   store i64 %95, i64* %93
>   call void @p1(%1* %54)
>   %96 = bitcast %0* %3 to [8 x i8]*
>   %97 = bitcast %1* %54 to [8 x i8]*
>   %98 = load [8 x i8]* %96
>   store [8 x i8] %98, [8 x i8]* %97
>   %99 = bitcast %0* %13 to i64*
>   %100 = load i64* %99
>   %101 = sub i64 %100, 1
>   store i64 %101, i64* %99
>   %102 = bitcast %0* %13 to [8 x i8]*
>   %103 = getelementptr %1* %54, i64 0, i32 0, i32 8
>   %104 = bitcast i8* %103 to [8 x i8]*
>   %105 = load [8 x i8]* %102
>   store [8 x i8] %105, [8 x i8]* %104
>   call void @p1(%1* %54)
>   call void @llvm.stackrestore(i8* %53)
>   %106 = load %0** %31
>   %107 = ptrtoint %0* %106 to i64
>   %108 = icmp ne i64 %107, 0
>   br i1 %108, label %111, label %117
>
> ; <label>:109                                     ; preds = %83
>   %110 = bitcast %0* %80 to i8*
>   call void @destroy(i8* inttoptr (i64 161025200 to i8*), i8* inttoptr
(i64 160883800 to i8*), i8* %110)
>   br label %89
>
> ; <label>:111                                     ; preds = %89
>   %112 = bitcast %0* %106 to i64*
>   %113 = getelementptr i64* %112, i32 -1
>   %114 = load i64* %113
>   %115 = sub i64 %114, 1
>   store i64 %115, i64* %113
>   %116 = icmp ne i64 %115, 0
>   br i1 %116, label %118, label %117
>
> ; <label>:117                                     ; preds = %118, %111,
%89
>   call void @llvm.stackrestore(i8* %30)
>   call void @llvm.stackrestore(i8* %12)
>   call void @llvm.stackrestore(i8* %2)
>   ret void
>
> ; <label>:118                                     ; preds = %111
>   %119 = bitcast %0* %106 to i8*
>   call void @destroy(i8* inttoptr (i64 161025200 to i8*), i8* inttoptr
(i64 161028240 to i8*), i8* %119)
>   br label %117
> }
>
> UNREACHABLE executed!
> Stack dump:
> 0.      Running pass 'X86 DAG->DAG Instruction Selection' on function
'@p1'
> Aborted
>
> I know this code is bulky and complicated, but can you just suggest me
possible causes of such error? Thanks.
>

Is your copy of LLVM built with assertions enabled?  If not, you may want
to try rebuilding LLVM with assertions to see if you get any assertion
failures which may give more information about the problem.

> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111102/94ed3924/attachment.html>


More information about the llvm-dev mailing list