Test Failure: Transforms/LoopVectorize/X86/propagate-metadata.ll

Test source: git

Comments: Bug in IR semantics or optimization: escapes noescape pointer

Log:

Source: <stdin>
-- 1. ModuleToFunctionPassAdaptor
-- 1. PassManager<Function> : Skipping NOP
-- 2. LoopVectorizePass

----------------------------------------
define void @no_propagate_range_metadata(ptr nowrite %first.coerce, ptr noread nowrite %last.coerce, ptr nocapture %result) {
for.body.preheader:
  br label %for.body

for.body:
  %result.addr.05 = phi ptr [ %incdec.ptr, %for.body ], [ nocapture %result, %for.body.preheader ]
  %first.sroa.0.04 = phi ptr [ %incdec.ptr.i.i.i, %for.body ], [ nowrite %first.coerce, %for.body.preheader ]
  %#0 = load i8, ptr %first.sroa.0.04, align 1
  %#0_range = !range i8 %#0, i8 0, i8 2
  store i8 %#0_range, ptr %result.addr.05, align 1
  %incdec.ptr.i.i.i = gep inbounds ptr %first.sroa.0.04, 1 x i64 1
  %incdec.ptr = gep inbounds ptr %result.addr.05, 1 x i64 1
  %lnot.i = icmp eq ptr %incdec.ptr.i.i.i, noread nowrite %last.coerce
  br i1 %lnot.i, label %for.end.loopexit, label %for.body

for.end.loopexit:
  ret void
}
Transformation seems to be correct! (syntactically equal)

-- 3. LoopVectorizePass

----------------------------------------
define void @no_propagate_range_metadata(ptr nowrite %first.coerce, ptr noread nowrite %last.coerce, ptr nocapture %result) {
for.body.preheader:
  br label %for.body

for.body:
  %result.addr.05 = phi ptr [ %incdec.ptr, %for.body ], [ nocapture %result, %for.body.preheader ]
  %first.sroa.0.04 = phi ptr [ %incdec.ptr.i.i.i, %for.body ], [ nowrite %first.coerce, %for.body.preheader ]
  %#0 = load i8, ptr %first.sroa.0.04, align 1
  %#0_range = !range i8 %#0, i8 0, i8 2
  store i8 %#0_range, ptr %result.addr.05, align 1
  %incdec.ptr.i.i.i = gep inbounds ptr %first.sroa.0.04, 1 x i64 1
  %incdec.ptr = gep inbounds ptr %result.addr.05, 1 x i64 1
  %lnot.i = icmp eq ptr %incdec.ptr.i.i.i, noread nowrite %last.coerce
  br i1 %lnot.i, label %for.end.loopexit, label %for.body

for.end.loopexit:
  ret void
}
=>
define void @no_propagate_range_metadata(ptr nowrite %first.coerce, ptr noread nowrite %last.coerce, ptr nocapture %result) {
iter.check:
  %first.coerce4 = ptrtoint ptr nowrite %first.coerce to i64
  %last.coerce3 = ptrtoint ptr noread nowrite %last.coerce to i64
  %first.coerce2 = ptrtoint ptr nowrite %first.coerce to i64
  %result1 = ptrtoint ptr nocapture %result to i64
  %#0 = sub i64 %last.coerce3, %first.coerce4
  %min.iters.check = icmp ult i64 %#0, 8
  br i1 %min.iters.check, label %vec.epilog.scalar.ph, label %vector.memcheck

vector.memcheck:
  %#1 = sub i64 %result1, %first.coerce2
  %diff.check = icmp ult i64 %#1, 32
  br i1 %diff.check, label %vec.epilog.scalar.ph, label %vector.main.loop.iter.check

vector.main.loop.iter.check:
  %min.iters.check5 = icmp ult i64 %#0, 32
  br i1 %min.iters.check5, label %vec.epilog.ph, label %vector.ph

vector.ph:
  %n.mod.vf = urem i64 %#0, 32
  %n.vec = sub i64 %#0, %n.mod.vf
  br label %vector.body

vector.body:
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %#2 = add i64 %index, 0
  %next.gep = gep ptr nocapture %result, 1 x i64 %#2
  %#3 = add i64 %index, 0
  %next.gep6 = gep ptr nowrite %first.coerce, 1 x i64 %#3
  %#4 = gep ptr %next.gep6, 1 x i32 0
  %#5 = gep ptr %next.gep6, 1 x i32 16
  %wide.load = load <16 x i8>, ptr %#4, align 1
  %wide.load7 = load <16 x i8>, ptr %#5, align 1
  %#6 = gep ptr %next.gep, 1 x i32 0
  %#7 = gep ptr %next.gep, 1 x i32 16
  store <16 x i8> %wide.load, ptr %#6, align 1
  store <16 x i8> %wide.load7, ptr %#7, align 1
  %index.next = add nuw i64 %index, 32
  %#8 = icmp eq i64 %index.next, %n.vec
  br i1 %#8, label %middle.block, label %vector.body

middle.block:
  %cmp.n = icmp eq i64 %#0, %n.vec
  br i1 %cmp.n, label %for.end.loopexit, label %vec.epilog.iter.check

vec.epilog.iter.check:
  %ind.end12 = gep ptr nowrite %first.coerce, 1 x i64 %n.vec
  %ind.end10 = gep ptr nocapture %result, 1 x i64 %n.vec
  %n.vec.remaining = sub i64 %#0, %n.vec
  %min.epilog.iters.check = icmp ult i64 %n.vec.remaining, 8
  br i1 %min.epilog.iters.check, label %vec.epilog.scalar.ph, label %vec.epilog.ph

vec.epilog.ph:
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.mod.vf8 = urem i64 %#0, 8
  %n.vec9 = sub i64 %#0, %n.mod.vf8
  %ind.end = gep ptr nocapture %result, 1 x i64 %n.vec9
  %ind.end11 = gep ptr nowrite %first.coerce, 1 x i64 %n.vec9
  br label %vec.epilog.vector.body

vec.epilog.vector.body:
  %index14 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next18, %vec.epilog.vector.body ]
  %#9 = add i64 %index14, 0
  %next.gep15 = gep ptr nocapture %result, 1 x i64 %#9
  %#10 = add i64 %index14, 0
  %next.gep16 = gep ptr nowrite %first.coerce, 1 x i64 %#10
  %#11 = gep ptr %next.gep16, 1 x i32 0
  %wide.load17 = load <8 x i8>, ptr %#11, align 1
  %#12 = gep ptr %next.gep15, 1 x i32 0
  store <8 x i8> %wide.load17, ptr %#12, align 1
  %index.next18 = add nuw i64 %index14, 8
  %#13 = icmp eq i64 %index.next18, %n.vec9
  br i1 %#13, label %vec.epilog.middle.block, label %vec.epilog.vector.body

vec.epilog.middle.block:
  %cmp.n19 = icmp eq i64 %#0, %n.vec9
  br i1 %cmp.n19, label %for.end.loopexit, label %vec.epilog.scalar.ph

vec.epilog.scalar.ph:
  %bc.resume.val = phi ptr [ %ind.end, %vec.epilog.middle.block ], [ %ind.end10, %vec.epilog.iter.check ], [ nocapture %result, %vector.memcheck ], [ nocapture %result, %iter.check ]
  %bc.resume.val13 = phi ptr [ %ind.end11, %vec.epilog.middle.block ], [ %ind.end12, %vec.epilog.iter.check ], [ nowrite %first.coerce, %vector.memcheck ], [ nowrite %first.coerce, %iter.check ]
  br label %for.body

for.body:
  %result.addr.05 = phi ptr [ %incdec.ptr, %for.body ], [ %bc.resume.val, %vec.epilog.scalar.ph ]
  %first.sroa.0.04 = phi ptr [ %incdec.ptr.i.i.i, %for.body ], [ %bc.resume.val13, %vec.epilog.scalar.ph ]
  %#14 = load i8, ptr %first.sroa.0.04, align 1
  %#14_range = !range i8 %#14, i8 0, i8 2
  store i8 %#14_range, ptr %result.addr.05, align 1
  %incdec.ptr.i.i.i = gep inbounds ptr %first.sroa.0.04, 1 x i64 1
  %incdec.ptr = gep inbounds ptr %result.addr.05, 1 x i64 1
  %lnot.i = icmp eq ptr %incdec.ptr.i.i.i, noread nowrite %last.coerce
  br i1 %lnot.i, label %for.end.loopexit, label %for.body

for.end.loopexit:
  ret void
}
Transformation doesn't verify! (unsound)
ERROR: Source is more defined than target

Example:
ptr nowrite %first.coerce = pointer(non-local, block_id=1, offset=0, attrs=4) / Address=#x000000000000000b
ptr noread nowrite %last.coerce = pointer(non-local, block_id=0, offset=12, attrs=6) / Address=#x000000000000000c
ptr nocapture %result = pointer(non-local, block_id=2, offset=6, attrs=1) / Address=#x0000000000000009

Source:
  >> Jump to %for.body
ptr %result.addr.05 = pointer(non-local, block_id=2, offset=6, attrs=1) / Address=#x0000000000000009
ptr %first.sroa.0.04 = pointer(non-local, block_id=1, offset=0, attrs=4) / Address=#x000000000000000b
i8 %#0 = poison
i8 %#0_range = poison
ptr %incdec.ptr.i.i.i = pointer(non-local, block_id=1, offset=1, attrs=4) / Address=#x000000000000000c
ptr %incdec.ptr = pointer(non-local, block_id=2, offset=7, attrs=1) / Address=#x000000000000000a
i1 %lnot.i = #x1 (1)
  >> Jump to %for.end.loopexit

SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 >	size: 0	align: 1	alloc type: 0	alive: false	address: 0
Block 1 >	size: 1	align: 1	alloc type: 0	alive: true	address: 11
Block 2 >	size: 8	align: 1	alloc type: 0	alive: true	address: 3
Block 3 >	size: 1	align: 1	alloc type: 0	alive: true	address: 2

Target:
i64 %first.coerce4 = #x000000000000000b (11)
i64 %last.coerce3 = #x000000000000000c (12)
i64 %first.coerce2 = #x000000000000000b (11)
i64 %result1 = UB triggered!


Pass: LoopVectorizePass
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' '-mtriple=x86_64-unknown-linux-gnu' '-passes=loop-vectorize' '-tv-smt-to=20000' '-tv-report-dir=/home/nlopes/alive2/build/logs' '-tv-smt-stats'
Wrote bitcode to: "/home/nlopes/alive2/build/logs/in_VNo6HrCI_Vubl.bc"


------------------- SMT STATS -------------------
Num queries: 35
Num invalid: 0
Num skips:   0
Num trivial: 11 (23.9%)
Num timeout: 0 (0.0%)
Num errors:  0 (0.0%)
Num SAT:     22 (62.9%)
Num UNSAT:   13 (37.1%)
Alive2: Transform doesn't verify; aborting!

stderr:

RUN: at line 1: /home/nlopes/alive2/build/opt-alive.sh -S -mtriple="x86_64-unknown-linux-gnu" -passes=loop-vectorize < /bitbucket/nlopes/llvm/llvm/test/Transforms/LoopVectorize/X86/propagate-metadata.ll | /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/LoopVectorize/X86/propagate-metadata.ll
+ /home/nlopes/alive2/build/opt-alive.sh -S -mtriple=x86_64-unknown-linux-gnu -passes=loop-vectorize
+ /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/LoopVectorize/X86/propagate-metadata.ll

FileCheck error: '<stdin>' is empty.
FileCheck command line:  /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/LoopVectorize/X86/propagate-metadata.ll

 

<-- Back