Hi everyone,
I started digging into MemDep to enhance devirtualization and I found out
that it doesn't handle invariant.group if it will find GEP 0, 0.
If I understand it correctly getelementptr with zeros is just bitcast. Is
there any good reason why it is not canonicalized into bitcast?
Example:
define void @_Z5testGv() local_unnamed_addr #0 {
entry:
* %a* = alloca %struct.A, align 8
%0 = bitcast %struct.A* %a to i8*
call void @llvm.lifetime.start(i64 8, i8* nonnull %0) #3
* %1* = getelementptr inbounds %struct.A, %struct.A* %a, i64 0, i32 0
store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, {
[3 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32
(...)*** *%1*, align 8, !tbaa !8, !invariant.group !10
call void @_Z1zR1A(%struct.A* nonnull dereferenceable(8) %a) #3
%2 = load i32, i32* @glob, align 4, !tbaa !4
%tobool.i = icmp eq i32 %2, 0
br i1 %tobool.i, label %_Z1gR1A.exit, label %if.then.i
if.then.i: ; preds = %entry
* %3* = bitcast %struct.A* *%a* to void (%struct.A*)***
%vtable.i = load void (%struct.A*)**, void (%struct.A*)*** *%3*, align 8,
!tbaa !8, !invariant.group !10
%4 = load void (%struct.A*)*, void (%struct.A*)** %vtable.i, align 8,
!invariant.load !11
call void %4(%struct.A* nonnull %a) #3
br label %_Z1gR1A.exit
_Z1gR1A.exit: ; preds = %entry,
%if.then.i
call void @llvm.lifetime.end(i64 8, i8* nonnull %0) #3
ret void
}
I can easily fix it in MemDep here
https://github.com/llvm-mirror/llvm/blob/master/lib/Analysis/MemoryDependenceAnalysis.cpp#L361
by adding gep with zeros, but it sounds like a canonicalization problem for
me.
Piotr
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20161223/d7a08d38/attachment.html>
On Fri, Dec 23, 2016 at 8:12 AM, Piotr Padlewski via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Hi everyone, > > I started digging into MemDep to enhance devirtualization and I found out > that it doesn't handle invariant.group if it will find GEP 0, 0. > If I understand it correctly getelementptr with zeros is just bitcast. Is > there any good reason why it is not canonicalized into bitcast? >Hi, is there any particular reason why you're trying to fix this in MemDep (and not in MemSSA?) -- Davide "There are no solved problems; there are only problems that are more or less solved" -- Henri Poincare
2016-12-23 17:22 GMT+01:00 Davide Italiano <davide at freebsd.org>:> On Fri, Dec 23, 2016 at 8:12 AM, Piotr Padlewski via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > Hi everyone, > > > > I started digging into MemDep to enhance devirtualization and I found out > > that it doesn't handle invariant.group if it will find GEP 0, 0. > > If I understand it correctly getelementptr with zeros is just bitcast. Is > > there any good reason why it is not canonicalized into bitcast? > > > > Hi, > is there any particular reason why you're trying to fix this in MemDep > (and not in MemSSA?) > > GVN uses MemDep and MemSSA doesn't handle invariant.group. I was toldthat MemDep won't go out soon and it is easier for me right now to fix my stuff there than in MemSSA. I have plans to write support for MemSSA, but probably not in near future.> -- > Davide > > "There are no solved problems; there are only problems that are more > or less solved" -- Henri Poincare >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161223/23f54487/attachment.html>