Test source: git
Source: /bitbucket/nlopes/llvm/llvm/test/Transforms/StructurizeCFG/loop-break-phi.ll -- 1. ModuleToFunctionPassAdaptor -- 1. PassManager<Function> : Skipping NOP -- 2. StructurizeCFGPass ---------------------------------------- define float @while_break(i32 %z, float %v, i32 %x, i32 %y) { entry: br label %header header: %v.1 = phi float [ %v, %entry ], [ %v.2, %latch ] %ind = phi i32 [ 0, %entry ], [ %ind.inc, %latch ] %cc = icmp slt i32 %ind, %x br i1 %cc, label %if, label %else if: %v.if = fadd float %v.1, 1.000000 br label %latch else: %cc2 = icmp slt i32 %ind, %y br i1 %cc2, label %latch, label %end latch: %v.2 = phi float [ %v.if, %if ], [ %v.1, %else ] %ind.inc = add i32 %ind, 1 %cc3 = icmp slt i32 %ind, %z br i1 %cc3, label %end, label %header end: %r = phi float [ %v.2, %latch ], [ %v.1, %else ] ret float %r } Transformation seems to be correct! (syntactically equal) -- 3. StructurizeCFGPass ---------------------------------------- define float @while_break(i32 %z, float %v, i32 %x, i32 %y) { entry: br label %header header: %v.1 = phi float [ %v, %entry ], [ %v.2, %latch ] %ind = phi i32 [ 0, %entry ], [ %ind.inc, %latch ] %cc = icmp slt i32 %ind, %x br i1 %cc, label %if, label %else if: %v.if = fadd float %v.1, 1.000000 br label %latch else: %cc2 = icmp slt i32 %ind, %y br i1 %cc2, label %latch, label %end latch: %v.2 = phi float [ %v.if, %if ], [ %v.1, %else ] %ind.inc = add i32 %ind, 1 %cc3 = icmp slt i32 %ind, %z br i1 %cc3, label %end, label %header end: %r = phi float [ %v.2, %latch ], [ %v.1, %else ] ret float %r } => define float @while_break(i32 %z, float %v, i32 %x, i32 %y) { entry: br label %header header: %v.1 = phi float [ %v, %entry ], [ %#3, %Flow2 ] %ind = phi i32 [ 0, %entry ], [ %#5, %Flow2 ] %cc = icmp sge i32 %ind, %x br i1 %cc, label %else, label %Flow else: %cc2 = icmp slt i32 %ind, %y br label %Flow Flow: %#0 = phi float [ %v.1, %else ], [ undef, %header ] %#1 = phi i1 [ %cc2, %else ], [ 0, %header ] %#2 = phi i1 [ 0, %else ], [ 1, %header ] br i1 %#2, label %if, label %Flow1 if: %v.if = fadd float %v.1, 1.000000 br label %Flow1 Flow1: %#3 = phi float [ %v.if, %if ], [ %#0, %Flow ] %#4 = phi i1 [ 1, %if ], [ %#1, %Flow ] br i1 %#4, label %latch, label %Flow2 latch: %ind.inc = add i32 %ind, 1 %cc3 = icmp slt i32 %ind, %z br label %Flow2 Flow2: %#5 = phi i32 [ %ind.inc, %latch ], [ undef, %Flow1 ] %#6 = phi i1 [ %cc3, %latch ], [ 1, %Flow1 ] br i1 %#6, label %end, label %header end: ret float %#3 } Transformation doesn't verify! (unsound) ERROR: Value mismatch Example: i32 %z = #x00000002 (2) float %v = undef i32 %x = #x00000002 (2) i32 %y = #x00000000 (0) Source: >> Jump to %header float %v.1 = #x00000000 (+0.0) i32 %ind = #x00000000 (0) i1 %cc = #x1 (1) >> Jump to %if float %v.if = #x3f800000 (1) >> Jump to %latch float %v.2 = #x3f800000 (1) [based on undef value] i32 %ind.inc = #x00000001 (1) i1 %cc3 = #x1 (1) >> Jump to %end float %r = #x3f800000 (1) [based on undef value] Target: >> Jump to %header float %v.1 = #x00000000 (+0.0) [based on undef value] i32 %ind = #x00000000 (0) i1 %cc = #x0 (0) >> Jump to %Flow float %#0 = #x00000000 (+0.0) [based on undef value] i1 %#1 = #x0 (0) i1 %#2 = #x1 (1) >> Jump to %if float %v.if = #x7f800040 (SNaN) >> Jump to %Flow1 float %#3 = #x7f900000 (SNaN) i1 %#4 = #x1 (1) >> Jump to %latch i32 %ind.inc = #x00000001 (1) i1 %cc3 = #x1 (1) >> Jump to %Flow2 i32 %#5 = #x00000001 (1) i1 %#6 = #x1 (1) >> Jump to %end Source value: #x3f800000 (1) Target value: #x7f900000 (SNaN) Pass: StructurizeCFGPass Command line: '/home/nlopes/llvm/build/bin/opt' '-load=/home/nlopes/alive2/build/tv/tv.so' '-load-pass-plugin=/home/nlopes/alive2/build/tv/tv.so' '-tv-exit-on-error' '-S' '-passes=structurizecfg' '/bitbucket/nlopes/llvm/llvm/test/Transforms/StructurizeCFG/loop-break-phi.ll' '-o' '-' '-tv-smt-to=20000' '-tv-report-dir=/home/nlopes/alive2/build/logs' '-tv-smt-stats' Wrote bitcode to: "/home/nlopes/alive2/build/logs/loop-break-phi_UMwny2CP_jxDY.bc" ------------------- SMT STATS ------------------- Num queries: 39 Num invalid: 0 Num skips: 0 Num trivial: 28 (41.8%) Num timeout: 0 (0.0%) Num errors: 0 (0.0%) Num SAT: 27 (69.2%) Num UNSAT: 12 (30.8%) Alive2: Transform doesn't verify; aborting!
RUN: at line 2: /home/nlopes/alive2/build/opt-alive.sh -S -passes='structurizecfg' /bitbucket/nlopes/llvm/llvm/test/Transforms/StructurizeCFG/loop-break-phi.ll -o - | /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/StructurizeCFG/loop-break-phi.ll + /home/nlopes/alive2/build/opt-alive.sh -S -passes=structurizecfg /bitbucket/nlopes/llvm/llvm/test/Transforms/StructurizeCFG/loop-break-phi.ll -o - + /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/StructurizeCFG/loop-break-phi.ll FileCheck error: '<stdin>' is empty. FileCheck command line: /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/StructurizeCFG/loop-break-phi.ll
NOTE: This test would pass if undef didn't exist!