Teach valuetracking that byval arguments with a specified alignment are
authorChris Lattner <sabre@nondot.org>
Mon, 23 May 2011 00:03:39 +0000 (00:03 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 23 May 2011 00:03:39 +0000 (00:03 +0000)
commitb3f0673d52b72f34434dec13c4e2044c82012ef6
treee2c468a159ebf2b8586cef5e319a9fce91c05068
parentae441cc33cee83a598f74e3d0447fe02157b0389
Teach valuetracking that byval arguments with a specified alignment are
aligned.

Teach memcpyopt to not give up all hope when confonted with an underaligned
memcpy feeding an overaligned byval.  If the *source* of the memcpy can be
determined to be adequeately aligned, or if it can be forced to be, we can
eliminate the memcpy.

This addresses PR9794.  We now compile the example into:

define i32 @f(%struct.p* nocapture byval align 8 %q) nounwind ssp {
entry:
  %call = call i32 @g(%struct.p* byval align 8 %q) nounwind
  ret i32 %call
}

in both x86-64 and x86-32 mode.  We still don't get a tailcall though,
because tailcalls apparently can't handle byval.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131884 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ValueTracking.cpp
lib/Transforms/Scalar/MemCpyOptimizer.cpp
test/Transforms/MemCpyOpt/memcpy.ll