<div dir="ltr"><div>Hi,</div><div><br></div><div>I'm generating IR for a factorial function that looks like below. When I call the verifyFunction, it fails validation with the error message Terminator found in the middle of a basic block. label %then</div><div><br></div><div>The resulting IR still works fine but I'm not sure if the code generation should be done in a better way for the if/then block below.</div><div><br></div><div>Thanks in advance,</div><div>Vijay</div><div><br></div>define double @fact(double %n) {<br>entry:<br>  %n1 = alloca double, align 8<br>  store double %n, double* %n1, align 8<br>  %n2 = load double, double* %n1, align 8<br>  %cmptmp = fcmp ule double %n2, 1.000000e+00<br>  %booltmp = uitofp i1 %cmptmp to double<br>  %ifcond = fcmp one double %booltmp, 0.000000e+00<br>  br i1 %ifcond, label %then, label %ifcont<br><br>then:                                             ; preds = %entry<br>  ret double 1.000000e+00<br>  br label %ifcont<br><br>ifcont:                                           ; preds = %then, %entry<br>  %n3 = load double, double* %n1, align 8<br>  %n4 = load double, double* %n1, align 8<br>  %subtmp = fsub double %n4, 1.000000e+00<br>  %calltmp = call double @fact(double %subtmp)<br>  %multmp = fmul double %n3, %calltmp<br>  ret double %multmp<br>}<br>Validating function...<br>Terminator found in the middle of a basic block!<br>label %then<br>Validation failed<br><div><br></div></div>