Test source: git
Source: /bitbucket/nlopes/llvm/llvm/test/Transforms/LoopUnroll/peel-last-iteration-with-variable-trip-count.ll
-- 1. ModuleToFunctionPassAdaptor
-- 1. PassManager<Function> : Skipping NOP
-- 2. LoopUnrollPass
----------------------------------------
declare void @foo(i32)
define i32 @peel_last_with_trip_count_check_lcssa_phi(i32 %n) {
entry:
%sub = add i32 %n, 4294967295
br label %loop
loop:
%iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
%c = icmp eq i32 %iv, %sub
%sel = select i1 %c, i32 1, i32 2
call void @foo(i32 %sel)
%iv.next = add i32 %iv, 1
%ec = icmp ne i32 %iv.next, %n
br i1 %ec, label %loop, label %exit
exit:
%sel.lcssa = phi i32 [ %sel, %loop ]
ret i32 %sel.lcssa
}
Transformation seems to be correct! (syntactically equal)
-- 3. LoopUnrollPass
----------------------------------------
declare void @foo(i32)
define i32 @peel_last_with_trip_count_check_lcssa_phi(i32 %n) {
entry:
%sub = add i32 %n, 4294967295
br label %loop
loop:
%iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
%c = icmp eq i32 %iv, %sub
%sel = select i1 %c, i32 1, i32 2
call void @foo(i32 %sel)
%iv.next = add i32 %iv, 1
%ec = icmp ne i32 %iv.next, %n
br i1 %ec, label %loop, label %exit
exit:
%sel.lcssa = phi i32 [ %sel, %loop ]
ret i32 %sel.lcssa
}
=>
declare void @foo(i32)
define i32 @peel_last_with_trip_count_check_lcssa_phi(i32 %n) {
entry:
%sub = add i32 %n, 4294967295
%#0 = icmp ne i32 %sub, 0
br i1 %#0, label %entry.split, label %exit.peel.begin
entry.split:
br label %loop
loop:
%iv = phi i32 [ 0, %entry.split ], [ %iv.next, %loop ]
call void @foo(i32 2)
%iv.next = add nuw i32 %iv, 1
%#1 = sub i32 %n, 1
%ec = icmp ne i32 %iv.next, %#1
br i1 %ec, label %loop, label %exit.peel.begin.loopexit
exit.peel.begin.loopexit:
%.ph = phi i32 [ %iv.next, %loop ]
br label %exit.peel.begin
exit.peel.begin:
%#2 = phi i32 [ 0, %entry ], [ %.ph, %exit.peel.begin.loopexit ]
br label %loop.peel
loop.peel:
%c.peel = icmp eq i32 %#2, %sub
%sel.peel = select i1 %c.peel, i32 1, i32 2
call void @foo(i32 %sel.peel)
%iv.next.peel = add i32 %#2, 1
%ec.peel = icmp ne i32 %iv.next.peel, %n
br i1 %ec.peel, label %exit.peel.next, label %exit.peel.next
exit.peel.next:
br label %loop.peel.next
loop.peel.next:
br label %exit
exit:
ret i32 %sel.peel
}
Transformation doesn't verify! (unsound)
ERROR: Source is more defined than target
Example:
i32 %n = poison
Source:
i32 %sub = poison
>> Jump to %loop
i32 %iv = #x00000000 (0)
i1 %c = poison
i32 %sel = poison
void = function did not return!
SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 > size: 0 align: 1 alloc type: 0 alive: false address: #x0
Block 1 > size: 0 align: 8 alloc type: 0 alive: true address: #x8
Target:
i32 %sub = poison
i1 %#0 = poison
UB triggered on br
TARGET MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 > size: 0 align: 1 alloc type: 0 alive: false address: #x0
Block 1 > size: 0 align: 8 alloc type: 0 alive: true address: #x8
Pass: LoopUnrollPass
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' '-p' 'loop-unroll' '-unroll-full-max-count=0' '-S' '/bitbucket/nlopes/llvm/llvm/test/Transforms/LoopUnroll/peel-last-iteration-with-variable-trip-count.ll' '-tv-smt-to=20000' '-tv-report-dir=/home/nlopes/alive2/build/logs' '-tv-smt-stats'
Wrote bitcode to: "/home/nlopes/alive2/build/logs/peel-last-iteration-with-variable-trip-count_5DKKfhlP_e09i.bc"
------------------- SMT STATS -------------------
Num queries: 22
Num invalid: 0
Num skips: 0
Num trivial: 1 (4.3%)
Num timeout: 0 (0.0%)
Num errors: 1 (4.5%)
Num SAT: 19 (86.4%)
Num UNSAT: 2 (9.1%)
Alive2: Transform doesn't verify; aborting!
Transforms/LoopUnroll/peel-last-iteration-with-variable-trip-count.ll' FAILED ******************** Exit Code: 2 Command Output (stdout): -- # RUN: at line 2 /home/nlopes/alive2/build/opt-alive.sh -p loop-unroll -unroll-full-max-count=0 -S /bitbucket/nlopes/llvm/llvm/test/Transforms/LoopUnroll/peel-last-iteration-with-variable-trip-count.ll | /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/LoopUnroll/peel-last-iteration-with-variable-trip-count.ll # executed command: /home/nlopes/alive2/build/opt-alive.sh -p loop-unroll -unroll-full-max-count=0 -S /bitbucket/nlopes/llvm/llvm/test/Transforms/LoopUnroll/peel-last-iteration-with-variable-trip-count.ll # .---command stderr------------ # `----------------------------- # error: command failed with exit status: 1 # executed command: /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/LoopUnroll/peel-last-iteration-with-variable-trip-count.ll # .---command stderr------------ # | FileCheck error: '<stdin>' is empty. # | FileCheck command line: /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/LoopUnroll/peel-last-iteration-with-variable-trip-count.ll # `----------------------------- # error: command failed with exit status: 2 --