[llvm-bugs] [Bug 47343] New: opt -loop-vectorize crashes with "PHINode should have one entry for each predecessor of its parent basic block!"
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Aug 28 04:12:42 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=47343
Bug ID: 47343
Summary: opt -loop-vectorize crashes with "PHINode should have
one entry for each predecessor of its parent basic
block!"
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Loop Optimizer
Assignee: unassignedbugs at nondot.org
Reporter: mikael.holmen at ericsson.com
CC: llvm-bugs at lists.llvm.org
Created attachment 23902
--> https://bugs.llvm.org/attachment.cgi?id=23902&action=edit
bbi-46598.ll
Reproduce with:
opt -loop-vectorize -o /dev/null -S bbi-46598.ll -mtriple=arm64-apple-ios
Result:
PHINode should have one entry for each predecessor of its parent basic block!
%4 = phi i8* [ %.lcssa, %if.end.us.us.us.preheader ], [ %.lcssa,
%middle.block ]
opt: ../lib/Transforms/Vectorize/LoopVectorize.cpp:8472: bool
llvm::LoopVectorizePass::processLoop(llvm::Loop *): Assertion
`!verifyFunction(*L->getHeader()->getParent(), &dbgs())' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace.
Stack dump:
0. Program arguments: /data/repo/master/llvm/build-all/bin/opt
-loop-vectorize -o /dev/null -S bbi-46598.ll -mtriple=arm64-apple-ios -debug
-print-after-all
1. Running pass 'Function Pass Manager' on module 'bbi-46598.ll'.
2. Running pass 'Loop Vectorization' on function '@f'
/data/repo/master/llvm/build-all/bin/opt[0x47c4c14]
/data/repo/master/llvm/build-all/bin/opt(_ZN4llvm3sys17RunSignalHandlersEv+0xee)[0x47c279e]
/data/repo/master/llvm/build-all/bin/opt[0x47c4f2c]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890)[0x7f2c20115890]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f2c1ebbee97]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f2c1ebc0801]
/lib/x86_64-linux-gnu/libc.so.6(+0x3039a)[0x7f2c1ebb039a]
/lib/x86_64-linux-gnu/libc.so.6(+0x30412)[0x7f2c1ebb0412]
/data/repo/master/llvm/build-all/bin/opt(_ZN4llvm17LoopVectorizePass11processLoopEPNS_4LoopE+0x4768)[0x4951b88]
/data/repo/master/llvm/build-all/bin/opt(_ZN4llvm17LoopVectorizePass7runImplERNS_8FunctionERNS_15ScalarEvolutionERNS_8LoopInfoERNS_19TargetTransformInfoERNS_13DominatorTreeERNS_18BlockFrequencyInfoEPNS_17TargetLibraryInfoERNS_12DemandedBitsERNS_9AAResultsERNS_15AssumptionCacheERSt8functionIFRKNS_14LoopAccessInfoERNS_4LoopEEERNS_25OptimizationRemarkEmitterEPNS_18ProfileSummaryInfoE+0x1d2)[0x49526b2]
/data/repo/master/llvm/build-all/bin/opt[0x4958288]
/data/repo/master/llvm/build-all/bin/opt(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0x47f)[0x3ff888f]
/data/repo/master/llvm/build-all/bin/opt(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x38)[0x3fff128]
/data/repo/master/llvm/build-all/bin/opt(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x35d)[0x3ff8e5d]
/data/repo/master/llvm/build-all/bin/opt(main+0x339f)[0x26e3d0f]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7f2c1eba1b97]
/data/repo/master/llvm/build-all/bin/opt(_start+0x2a)[0x26ca02a]
Abort (core dumped)
When it fails the function looks like this:
define void @f() {
entry:
br label %for.body3.lr.ph.outer
for.body3.lr.ph.outer: ; preds = %cleanup, %entry
%0 = load i8*, i8** @d, align 1
br i1 true, label %if.end.us.us.us.preheader, label %land.end.preheader
land.end.preheader: ; preds =
%for.body3.lr.ph.outer
br label %land.end
if.end.us.us.us.preheader: ; preds =
%for.body3.lr.ph.outer
%.lcssa = phi i8* [ %0, %for.body3.lr.ph.outer ]
br i1 false, label %scalar.ph, label %vector.memcheck
vector.memcheck: ; preds =
%if.end.us.us.us.preheader
%scevgep = getelementptr i8, i8* %.lcssa, i64 1
%bound0 = icmp ult i8* bitcast (i32* @f.e to i8*), %scevgep
%bound1 = icmp ult i8* %0, getelementptr (i8, i8* bitcast (i32* @f.e to i8*),
i64 1)
%found.conflict = and i1 %bound0, %bound1
%memcheck.conflict = and i1 %found.conflict, true
br i1 %memcheck.conflict, label %scalar.ph, label %vector.ph
vector.ph: ; preds = %vector.memcheck
br label %vector.body
vector.body: ; preds = %vector.body,
%vector.ph
%index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%offset.idx = add i32 undef, %index
%1 = add i32 %offset.idx, 0
%2 = add i32 %offset.idx, 4
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i8 undef, i8* %0, align 1
store i8 undef, i8* %0, align 1
store i8 undef, i8* %0, align 1
store i8 undef, i8* %0, align 1
store i8 undef, i8* %0, align 1
store i8 undef, i8* %0, align 1
store i8 undef, i8* %0, align 1
store i8 undef, i8* %0, align 1
%index.next = add i32 %index, 8
%3 = icmp eq i32 %index.next, undef
br i1 %3, label %middle.block, label %vector.body, !llvm.loop !5
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i32 undef, undef
br i1 %cmp.n, label %for.end9.loopexit, label %scalar.ph
scalar.ph: ; preds = %middle.block,
%vector.memcheck, %if.end.us.us.us.preheader
%4 = phi i8* [ %.lcssa, %if.end.us.us.us.preheader ], [ %.lcssa,
%middle.block ]
%bc.resume.val = phi i32 [ undef, %middle.block ], [ undef,
%if.end.us.us.us.preheader ], [ undef, %vector.memcheck ]
br label %if.end.us.us.us
if.end.us.us.us: ; preds = %scalar.ph,
%if.end.us.us.us
%h.14.us.us.us = phi i32 [ %inc.us.us.us, %if.end.us.us.us ], [
%bc.resume.val, %scalar.ph ]
%conv6.us.us.us = zext i1 false to i32
store i32 %conv6.us.us.us, i32* @f.e, align 1
store i8 undef, i8* %4, align 1
%inc.us.us.us = add nsw i32 %h.14.us.us.us, 1
%tobool2.not.us.us.us = icmp eq i32 %inc.us.us.us, 0
br i1 %tobool2.not.us.us.us, label %for.end9.loopexit, label
%if.end.us.us.us, !llvm.loop !7
land.end: ; preds =
%land.end.preheader, %if.end
br i1 false, label %if.end, label %cleanup
if.end: ; preds = %land.end
br i1 true, label %for.end9.loopexit1, label %land.end
cleanup: ; preds = %land.end
br label %for.body3.lr.ph.outer
for.end9.loopedefine void @f() {
entry:
br label %for.body3.lr.ph.outer
for.body3.lr.ph.outer: ; preds = %cleanup, %entry
%0 = load i8*, i8** @d, align 1
br i1 true, label %if.end.us.us.us.preheader, label %land.end.preheader
land.end.preheader: ; preds =
%for.body3.lr.ph.outer
br label %land.end
if.end.us.us.us.preheader: ; preds =
%for.body3.lr.ph.outer
%.lcssa = phi i8* [ %0, %for.body3.lr.ph.outer ]
br i1 false, label %scalar.ph, label %vector.memcheck
vector.memcheck: ; preds =
%if.end.us.us.us.preheader
%scevgep = getelementptr i8, i8* %.lcssa, i64 1
%bound0 = icmp ult i8* bitcast (i32* @f.e to i8*), %scevgep
%bound1 = icmp ult i8* %0, getelementptr (i8, i8* bitcast (i32* @f.e to i8*),
i64 1)
%found.conflict = and i1 %bound0, %bound1
%memcheck.conflict = and i1 %found.conflict, true
br i1 %memcheck.conflict, label %scalar.ph, label %vector.ph
vector.ph: ; preds = %vector.memcheck
br label %vector.body
vector.body: ; preds = %vector.body,
%vector.ph
%index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%offset.idx = add i32 undef, %index
%1 = add i32 %offset.idx, 0
%2 = add i32 %offset.idx, 4
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
store i8 undef, i8* %0, align 1
store i8 undef, i8* %0, align 1
store i8 undef, i8* %0, align 1
store i8 undef, i8* %0, align 1
store i8 undef, i8* %0, align 1
store i8 undef, i8* %0, align 1
store i8 undef, i8* %0, align 1
store i8 undef, i8* %0, align 1
%index.next = add i32 %index, 8
%3 = icmp eq i32 %index.next, undef
br i1 %3, label %middle.block, label %vector.body, !llvm.loop !5
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i32 undef, undef
br i1 %cmp.n, label %for.end9.loopexit, label %scalar.ph
scalar.ph: ; preds = %middle.block,
%vector.memcheck, %if.end.us.us.us.preheader
%4 = phi i8* [ %.lcssa, %if.end.us.us.us.preheader ], [ %.lcssa,
%middle.block ]
%bc.resume.val = phi i32 [ undef, %middle.block ], [ undef,
%if.end.us.us.us.preheader ], [ undef, %vector.memcheck ]
br label %if.end.us.us.us
if.end.us.us.us: ; preds = %scalar.ph,
%if.end.us.us.us
%h.14.us.us.us = phi i32 [ %inc.us.us.us, %if.end.us.us.us ], [
%bc.resume.val, %scalar.ph ]
%conv6.us.us.us = zext i1 false to i32
store i32 %conv6.us.us.us, i32* @f.e, align 1
store i8 undef, i8* %4, align 1
%inc.us.us.us = add nsw i32 %h.14.us.us.us, 1
%tobool2.not.us.us.us = icmp eq i32 %inc.us.us.us, 0
br i1 %tobool2.not.us.us.us, label %for.end9.loopexit, label
%if.end.us.us.us, !llvm.loop !7
land.end: ; preds =
%land.end.preheader, %if.end
br i1 false, label %if.end, label %cleanup
if.end: ; preds = %land.end
br i1 true, label %for.end9.loopexit1, label %land.end
cleanup: ; preds = %land.end
br label %for.body3.lr.ph.outer
for.end9.loopexit: ; preds = %middle.block,
%if.end.us.us.us
br label %for.end9
for.end9.loopexit1: ; preds = %if.end
br label %for.end9
for.end9: ; preds =
%for.end9.loopexit1, %for.end9.loopexit
ret void
}
xit: ; preds = %middle.block, %if.end.us.us.us
br label %for.end9
for.end9.loopexit1: ; preds = %if.end
br label %for.end9
for.end9: ; preds =
%for.end9.loopexit1, %for.end9.loopexit
ret void
}
In particular scalar.ph looks like this:
scalar.ph: ; preds = %middle.block,
%vector.memcheck, %if.end.us.us.us.preheader
%4 = phi i8* [ %.lcssa, %if.end.us.us.us.preheader ], [ %.lcssa,
%middle.block ]
%bc.resume.val = phi i32 [ undef, %middle.block ], [ undef,
%if.end.us.us.us.preheader ], [ undef, %vector.memcheck ]
br label %if.end.us.us.us
So the %4 phi is lacking an operand for %vector.memcheck.
This starts happening with commit f75564ad4e4:
Reland "[SCEVExpander] Add option to preserve LCSSA directly."
This reverts the revert commit dc2867576886247cbe351e7c63618c09ab6af808.
It includes a fix for Polly, which uses SCEVExpander on IR that is not
in LCSSA form. Set PreserveLCSSA = false in that case, to ensure we do
not introduce LCSSA phis where there were none before.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200828/bb2533cf/attachment.html>
More information about the llvm-bugs
mailing list