jeudi 1 décembre 2016

How comes the basic block does not have terminator?

So I am trying to generate code for an if statement but I am receiving "Basic Block in function (function_name) does not have terminator! label %then"

But if check the code generated it seems like the terminators are there for each block.

define void @M4_Main_main() {
%1 = call i8* @__lcpl_new(%struct.__lcpl_rtti* @RString)
%2 = bitcast i8* %1 to %struct.TString*
%3 = getelementptr %struct.TString, %struct.TString* %2, i32 0, i32 1
store i32 22, i32* %3
%4 = getelementptr %struct.TString, %struct.TString* %2, i32 0, i32 2
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @0, i32 0, i32 0), i8** %4
%5 = call i8* @__lcpl_new(%struct.__lcpl_rtti* @RIO)
%6 = bitcast i8* %5 to %struct.TIO*
%7 = call %struct.TIO* @M2_IO_out(%struct.TIO* %6, %struct.TString* %2)
br i1 true, label %then, label %else

then:                                             ; preds = %0
                                              ; No predecessors!
%9 = call i8* @__lcpl_new(%struct.__lcpl_rtti* @RString)
%10 = bitcast i8* %9 to %struct.TString*
%11 = getelementptr %struct.TString, %struct.TString* %10, i32 0, i32 1
store i32 12, i32* %11
%12 = getelementptr %struct.TString, %struct.TString* %10, i32 0, i32 2
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @1, i32 0, i32 0), i8** %12
%13 = call i8* @__lcpl_new(%struct.__lcpl_rtti* @RIO)
%14 = bitcast i8* %13 to %struct.TIO*
%15 = call %struct.TIO* @M2_IO_out(%struct.TIO* %14, %struct.TString* %10)
br label %ifcont

else:                                             ; preds = %0
                                              ; No predecessors!
br label %ifcont

ifcont:                                           ; preds = %16, %8
%iftmp = phi i32 [ <null operand!>, %8 ], [ <null operand!>, %16 ]
%17 = call i8* @__lcpl_new(%struct.__lcpl_rtti* @RString)
%18 = bitcast i8* %17 to %struct.TString*
%19 = getelementptr %struct.TString, %struct.TString* %18, i32 0, i32 1
store i32 22, i32* %19
%20 = getelementptr %struct.TString, %struct.TString* %18, i32 0, i32 2
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @2, i32 0, i32 0), i8** %20
%21 = call i8* @__lcpl_new(%struct.__lcpl_rtti* @RIO)
%22 = bitcast i8* %21 to %struct.TIO*
%23 = call %struct.TIO* @M2_IO_out(%struct.TIO* %22, %struct.TString* %18)
br i1 false, label %then1, label %else2

then1:                                            ; preds = %ifcont
                                              ; No predecessors!
br label %ifcont3

else2:                                            ; preds = %ifcont
                                              ; No predecessors!
%26 = call i8* @__lcpl_new(%struct.__lcpl_rtti* @RString)
%27 = bitcast i8* %26 to %struct.TString*
%28 = getelementptr %struct.TString, %struct.TString* %27, i32 0, i32 1
store i32 12, i32* %28
%29 = getelementptr %struct.TString, %struct.TString* %27, i32 0, i32 2
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @3, i32 0, i32 0), i8** %29
%30 = call i8* @__lcpl_new(%struct.__lcpl_rtti* @RIO)
%31 = bitcast i8* %30 to %struct.TIO*
%32 = call %struct.TIO* @M2_IO_out(%struct.TIO* %31, %struct.TString* %27)
br label %ifcont3

ifcont3:                                          ; preds = %25, %24
%iftmp4 = phi i32 [ <null operand!>, %24 ], [ <null operand!>, %25 ]
%33 = call i8* @__lcpl_new(%struct.__lcpl_rtti* @RString)
%34 = bitcast i8* %33 to %struct.TString*
%35 = getelementptr %struct.TString, %struct.TString* %34, i32 0, i32 1
store i32 4, i32* %35
%36 = getelementptr %struct.TString, %struct.TString* %34, i32 0, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @4, i32 0, i32 0), i8** %36
%37 = call i8* @__lcpl_new(%struct.__lcpl_rtti* @RIO)
%38 = bitcast i8* %37 to %struct.TIO*
%39 = call %struct.TIO* @M2_IO_out(%struct.TIO* %38, %struct.TString* %34)
ret void
}

I read that to terminate a block it should have either a return or a branch and all my blocks do have such a statement. What could be the problem here ?

Aucun commentaire:

Enregistrer un commentaire