基本块怎么没有终止符?

时间:2016-12-01 14:16:21

标签: if-statement llvm code-generation

所以我试图为if语句生成代码,但我收到“函数中的基本块(function_name)没有终止符! 标签%然后“

但是如果检查生成的代码,似乎每个块都有终结符。

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
}

我读到要终止一个块,它应该有一个返回或一个分支,我的所有块都有这样的声明。这可能是什么问题?

0 个答案:

没有答案