Lin, Jin via llvm-dev
2016-Dec-02 18:06 UTC
[llvm-dev] Is the instruction %4 = select i1 %tobool.i, metadata !12, metadata !10 legal?
Hi, The phase of instruction combine cannot handle the instruction %4 = select i1 %tobool.i, metadata !12, metadata !10 generated by the phase of CFG simplification and the compiler generates an assertion failure. I wonder whether this is valid LLVM IR: %4 = select i1 %tobool.i, metadata !12, metadata !10 Before CFGSimplify cond.true.i: ; preds = %entry %add.ptr.i = getelementptr inbounds i8, i8* %2, i64 8 %left_.i.i = bitcast i8* %add.ptr.i to i32** %3 = call i32** @llvm.fakeload.p0p0i32(i32** %left_.i.i, metadata !8) #6 br label %_ZN1G7insert_Ev.exit cond.false.i: ; preds = %entry %right_.i.i = getelementptr inbounds i8, i8* %2, i64 16 %4 = bitcast i8* %right_.i.i to i32** %5 = call i32** @llvm.fakeload.p0p0i32(i32** %4, metadata !11) #6 br label %_ZN1G7insert_Ev.exit After CFGSimplify %4 = select i1 %tobool.i, metadata !12, metadata !10 %add.ptr.i = getelementptr inbounds i8, i8* %2, i64 %3 %left_.i.i = bitcast i8* %add.ptr.i to i32** %5 = call i32** @llvm.fakeload.p0p0i32(i32** %left_.i.i, metadata %4) #6 %6 = load i32*, i32** %5, align 8, !tbaa !8 Thanks, Jin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161202/90c846a1/attachment.html>
Mehdi Amini via llvm-dev
2016-Dec-02 18:09 UTC
[llvm-dev] Is the instruction %4 = select i1 %tobool.i, metadata !12, metadata !10 legal?
> On Dec 2, 2016, at 10:06 AM, Lin, Jin via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hi, > > The phase of instruction combine cannot handle the instruction %4 = select i1 %tobool.i, metadata !12, metadata !10 generated by the phase of CFG simplification and the compiler generates an assertion failure. > > I wonder whether this is valid LLVM IR: > > %4 = select i1 %tobool.i, metadata !12, metadata !10No this does not seem valid to me. Is the verifier accepting it? (This is usually the easiest way to figure). — Mehdi> <> > > > Before CFGSimplify > > cond.true.i: ; preds = %entry > %add.ptr.i = getelementptr inbounds i8, i8* %2, i64 8 > %left_.i.i = bitcast i8* %add.ptr.i to i32** > %3 = call i32** @llvm.fakeload.p0p0i32(i32** %left_.i.i, metadata !8) #6 br label %_ZN1G7insert_Ev.exit > > cond.false.i: ; preds = %entry > %right_.i.i = getelementptr inbounds i8, i8* %2, i64 16 > %4 = bitcast i8* %right_.i.i to i32** > %5 = call i32** @llvm.fakeload.p0p0i32(i32** %4, metadata !11) #6 > br label %_ZN1G7insert_Ev.exit > > > After CFGSimplify > > %4 = select i1 %tobool.i, metadata !12, metadata !10 > %add.ptr.i = getelementptr inbounds i8, i8* %2, i64 %3 > %left_.i.i = bitcast i8* %add.ptr.i to i32** > %5 = call i32** @llvm.fakeload.p0p0i32(i32** %left_.i.i, metadata %4) #6 > %6 = load i32*, i32** %5, align 8, !tbaa !8 > > > Thanks, > > Jin > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev>-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161202/504b645d/attachment.html>
Lin, Jin via llvm-dev
2016-Dec-02 18:34 UTC
[llvm-dev] Is the instruction %4 = select i1 %tobool.i, metadata !12, metadata !10 legal?
Thanks Mehdi. I have confirmed that this instruction cannot pass with the verification and somehow it is generated by the CFGSimplify. That is a bug in that phase of CFGSimplify. Thanks, Jin From: mehdi.amini at apple.com [mailto:mehdi.amini at apple.com] Sent: Friday, December 2, 2016 10:10 AM To: Lin, Jin <jin.lin at intel.com> Cc: llvm-dev at lists.llvm.org Subject: Re: [llvm-dev] Is the instruction %4 = select i1 %tobool.i, metadata !12, metadata !10 legal? On Dec 2, 2016, at 10:06 AM, Lin, Jin via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote: Hi, The phase of instruction combine cannot handle the instruction %4 = select i1 %tobool.i, metadata !12, metadata !10 generated by the phase of CFG simplification and the compiler generates an assertion failure. I wonder whether this is valid LLVM IR: %4 = select i1 %tobool.i, metadata !12, metadata !10 No this does not seem valid to me. Is the verifier accepting it? (This is usually the easiest way to figure). — Mehdi Before CFGSimplify cond.true.i: ; preds = %entry %add.ptr.i = getelementptr inbounds i8, i8* %2, i64 8 %left_.i.i = bitcast i8* %add.ptr.i to i32** %3 = call i32** @llvm.fakeload.p0p0i32(i32** %left_.i.i, metadata !8) #6 br label %_ZN1G7insert_Ev.exit cond.false.i: ; preds = %entry %right_.i.i = getelementptr inbounds i8, i8* %2, i64 16 %4 = bitcast i8* %right_.i.i to i32** %5 = call i32** @llvm.fakeload.p0p0i32(i32** %4, metadata !11) #6 br label %_ZN1G7insert_Ev.exit After CFGSimplify %4 = select i1 %tobool.i, metadata !12, metadata !10 %add.ptr.i = getelementptr inbounds i8, i8* %2, i64 %3 %left_.i.i = bitcast i8* %add.ptr.i to i32** %5 = call i32** @llvm.fakeload.p0p0i32(i32** %left_.i.i, metadata %4) #6 %6 = load i32*, i32** %5, align 8, !tbaa !8 Thanks, Jin _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161202/85e2744a/attachment.html>
Caldarale, Charles R via llvm-dev
2016-Dec-02 18:51 UTC
[llvm-dev] Is the instruction %4 = select i1 %tobool.i, metadata !12, metadata !10 legal?
> From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] > On Behalf Of Lin, Jin via llvm-dev > Subject: [llvm-dev] Is the instruction %4 = select i1 %tobool.i, metadata !12, metadata !10 legal?> I wonder whether this is valid LLVM IR: > %4 = select i1 %tobool.i, metadata !12, metadata !10> Before CFGSimplify > cond.true.i: ; preds = %entry > %add.ptr.i = getelementptr inbounds i8, i8* %2, i64 8 > %left_.i.i = bitcast i8* %add.ptr.i to i32** > %3 = call i32** @llvm.fakeload.p0p0i32(i32** %left_.i.i, metadata !8) #6 br label %_ZN1G7insert_Ev.exit > cond.false.i: ; preds = %entry > %right_.i.i = getelementptr inbounds i8, i8* %2, i64 16 > %4 = bitcast i8* %right_.i.i to i32** > %5 = call i32** @llvm.fakeload.p0p0i32(i32** %4, metadata !11) #6 > br label %_ZN1G7insert_Ev.exit> After CFGSimplify > %4 = select i1 %tobool.i, metadata !12, metadata !10 > %add.ptr.i = getelementptr inbounds i8, i8* %2, i64 %3 > %left_.i.i = bitcast i8* %add.ptr.i to i32** > %5 = call i32** @llvm.fakeload.p0p0i32(i32** %left_.i.i, metadata %4) #6 > %6 = load i32*, i32** %5, align 8, !tbaa !8Is there any more to the original IR? I don't think CFGSimplify would have magically created %tobool.i, yet it doesn't appear in the provided before snippet. - Chuck
Lin, Jin via llvm-dev
2016-Dec-02 19:08 UTC
[llvm-dev] Is the instruction %4 = select i1 %tobool.i, metadata !12, metadata !10 legal?
To reproduce the issue, please use the command line "opt -simplifycfg filename". target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" %struct.G = type { %struct.ordered_index_node*, i32 } %struct.ordered_index_node = type { %struct.B, %struct.F } %struct.B = type { i32 } %struct.F = type { i32*, i32* } $_ZN1G13final_insert_Ev = comdat any $_ZN1G7insert_Ev = comdat any $_ZN1F4leftEv = comdat any $_ZN1F5rightEv = comdat any ; Function Attrs: uwtable define void @_Z3fn1v() local_unnamed_addr #0 { entry: %t = alloca %struct.G, align 8 %0 = bitcast %struct.G* %t to i8* call void @llvm.lifetime.start(i64 16, i8* %0) #5 call void @_ZN1G13final_insert_Ev(%struct.G* nonnull %t) call void @llvm.lifetime.end(i64 16, i8* %0) #5 ret void } ; Function Attrs: argmemonly nounwind declare void @llvm.lifetime.start(i64, i8* nocapture) #1 ; Function Attrs: uwtable define linkonce_odr void @_ZN1G13final_insert_Ev(%struct.G* %this) local_unnamed_addr #0 comdat align 2 { entry: %call = call dereferenceable(16) %struct.G* @_ZN1G5finalEv(%struct.G* %this) %link_point_c.i = getelementptr inbounds %struct.G, %struct.G* %call, i64 0, i32 1 %0 = load i32, i32* %link_point_c.i, align 8, !tbaa !1 %tobool.i = icmp eq i32 %0, 0 %1 = bitcast %struct.G* %call to i8** %2 = load i8*, i8** %1, align 8, !tbaa !7 br i1 %tobool.i, label %cond.false.i, label %cond.true.i cond.true.i: ; preds = %entry %add.ptr.i = getelementptr inbounds i8, i8* %2, i64 8 %left_.i.i = bitcast i8* %add.ptr.i to i32** %3 = call i32** @llvm..fakeload.p0p0i32(i32** %left_.i.i, metadata !8) #5 br label %_ZN1G7insert_Ev.exit cond.false.i: ; preds = %entry %right_.i.i = getelementptr inbounds i8, i8* %2, i64 16 %4 = bitcast i8* %right_.i.i to i32** %5 = call i32** @llvm..fakeload.p0p0i32(i32** %4, metadata !11) #5 br label %_ZN1G7insert_Ev.exit _ZN1G7insert_Ev.exit: ; preds = %cond.true.i, %cond.false.i %call4.sink.i = phi i32** [ %5, %cond.false.i ], [ %3, %cond.true.i ] %6 = load i32*, i32** %call4.sink.i, align 8, !tbaa !12 call void @_ZN18ordered_index_node9from_implEPi(i32* %6) ret void } ; Function Attrs: argmemonly nounwind declare void @llvm.lifetime.end(i64, i8* nocapture) #1 declare dereferenceable(16) %struct.G* @_ZN1G5finalEv(%struct.G*) local_unnamed_addr #2 ; Function Attrs: uwtable define linkonce_odr void @_ZN1G7insert_Ev(%struct.G* %this) local_unnamed_addr #0 comdat align 2 { entry: %link_point_c = getelementptr inbounds %struct.G, %struct.G* %this, i64 0, i32 1 %0 = load i32, i32* %link_point_c, align 8, !tbaa !1 %tobool = icmp eq i32 %0, 0 %1 = bitcast %struct.G* %this to i8** %2 = load i8*, i8** %1, align 8, !tbaa !7 br i1 %tobool, label %cond.false, label %cond.true cond.true: ; preds = %entry %add.ptr = getelementptr inbounds i8, i8* %2, i64 8 %left_.i = bitcast i8* %add.ptr to i32** %3 = call i32** @llvm..fakeload.p0p0i32(i32** %left_.i, metadata !8) #5 br label %cond.end cond.false: ; preds = %entry %right_.i = getelementptr inbounds i8, i8* %2, i64 16 %4 = bitcast i8* %right_.i to i32** %5 = call i32** @llvm..fakeload.p0p0i32(i32** %4, metadata !11) #5 br label %cond.end cond.end: ; preds = %cond.false, %cond.true %call4.sink = phi i32** [ %5, %cond.false ], [ %3, %cond.true ] %6 = load i32*, i32** %call4.sink, align 8, !tbaa !12 call void @_ZN18ordered_index_node9from_implEPi(i32* %6) ret void } declare void @_ZN18ordered_index_node9from_implEPi(i32*) local_unnamed_addr #2 ; Function Attrs: nounwind uwtable define linkonce_odr dereferenceable(8) i32** @_ZN1F4leftEv(%struct.F* %this) local_unnamed_addr #3 comdat align 2 { entry: %left_ = getelementptr inbounds %struct.F, %struct.F* %this, i64 0, i32 0 %0 = call i32** @llvm..fakeload.p0p0i32(i32** %left_, metadata !8) #5 ret i32** %0 } ; Function Attrs: nounwind uwtable define linkonce_odr dereferenceable(8) i32** @_ZN1F5rightEv(%struct.F* %this) local_unnamed_addr #3 comdat align 2 { entry: %right_ = getelementptr inbounds %struct.F, %struct.F* %this, i64 0, i32 1 %0 = call i32** @llvm..fakeload.p0p0i32(i32** %right_, metadata !11) #5 ret i32** %0 } ; Function Attrs: nounwind readnone declare i32** @llvm..fakeload.p0p0i32(i32**, metadata) #4 attributes #0 = { uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } attributes #1 = { argmemonly nounwind } attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } attributes #3 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } attributes #4 = { nounwind readnone } attributes #5 = { nounwind } !llvm.ident = !{!0} !0 = !{!"clang version 4.0.0 (branches/20501)"} !1 = !{!2, !6, i64 8} !2 = !{!"struct at _ZTS1G", !3, i64 0, !6, i64 8} !3 = !{!"pointer at _ZTSP18ordered_index_node", !4, i64 0} !4 = !{!"omnipotent char", !5, i64 0} !5 = !{!"Simple C++ TBAA"} !6 = !{!"int", !4, i64 0} !7 = !{!2, !3, i64 0} !8 = !{!9, !10, i64 0} !9 = !{!"struct at _ZTS1F", !10, i64 0, !10, i64 8} !10 = !{!"pointer at _ZTSPi", !4, i64 0} !11 = !{!9, !10, i64 8} !12 = !{!10, !10, i64 0} -----Original Message----- From: Caldarale, Charles R [mailto:Chuck.Caldarale at unisys.com] Sent: Friday, December 2, 2016 10:51 AM To: Lin, Jin <jin.lin at intel.com>; llvm-dev at lists.llvm.org Subject: RE: Is the instruction %4 = select i1 %tobool.i, metadata !12, metadata !10 legal?> From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] > On Behalf Of Lin, Jin via llvm-dev > Subject: [llvm-dev] Is the instruction %4 = select i1 %tobool.i, metadata !12, metadata !10 legal?> I wonder whether this is valid LLVM IR: > %4 = select i1 %tobool.i, metadata !12, metadata !10> Before CFGSimplify > cond.true.i: ; preds = %entry > %add.ptr.i = getelementptr inbounds i8, i8* %2, i64 8 > %left_.i.i = bitcast i8* %add.ptr.i to i32** > %3 = call i32** @llvm.fakeload.p0p0i32(i32** %left_.i.i, metadata !8) #6 br label %_ZN1G7insert_Ev.exit > cond.false.i: ; preds = %entry > %right_.i.i = getelementptr inbounds i8, i8* %2, i64 16 > %4 = bitcast i8* %right_.i.i to i32** > %5 = call i32** @llvm.fakeload.p0p0i32(i32** %4, metadata !11) #6 > br label %_ZN1G7insert_Ev.exit> After CFGSimplify > %4 = select i1 %tobool.i, metadata !12, metadata !10 > %add.ptr.i = getelementptr inbounds i8, i8* %2, i64 %3 > %left_.i.i = bitcast i8* %add.ptr.i to i32** > %5 = call i32** @llvm.fakeload.p0p0i32(i32** %left_.i.i, metadata %4) #6 > %6 = load i32*, i32** %5, align 8, !tbaa !8Is there any more to the original IR? I don't think CFGSimplify would have magically created %tobool.i, yet it doesn't appear in the provided before snippet. - Chuck
Reasonably Related Threads
- Is the instruction %4 = select i1 %tobool.i, metadata !12, metadata !10 legal?
- [LLVMdev] InstCombine "pessimizes" trunc i8 to i1?
- [LLVMdev] failed folding with constant array with opt -O3
- [LLVMdev] InstCombine "pessimizes" trunc i8 to i1?
- [LLVMdev] failed folding with constant array with opt -O3