[llvm-dev] verifyFunction fails validation with Terminator found in the middle of a basic block
Vijay via llvm-dev
llvm-dev at lists.llvm.org
Wed Oct 20 12:49:12 PDT 2021
Hi,
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
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.
Thanks in advance,
Vijay
define double @fact(double %n) {
entry:
%n1 = alloca double, align 8
store double %n, double* %n1, align 8
%n2 = load double, double* %n1, align 8
%cmptmp = fcmp ule double %n2, 1.000000e+00
%booltmp = uitofp i1 %cmptmp to double
%ifcond = fcmp one double %booltmp, 0.000000e+00
br i1 %ifcond, label %then, label %ifcont
then: ; preds = %entry
ret double 1.000000e+00
br label %ifcont
ifcont: ; preds = %then, %entry
%n3 = load double, double* %n1, align 8
%n4 = load double, double* %n1, align 8
%subtmp = fsub double %n4, 1.000000e+00
%calltmp = call double @fact(double %subtmp)
%multmp = fmul double %n3, %calltmp
ret double %multmp
}
Validating function...
Terminator found in the middle of a basic block!
label %then
Validation failed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211020/f762255d/attachment.html>
More information about the llvm-dev
mailing list