diff options
| author | Chris Lattner <sabre@nondot.org> | 2011-05-23 00:03:39 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2011-05-23 00:03:39 +0000 |
| commit | 83791ced7ba2a2d43d37bb1350f28ddf83c029f9 (patch) | |
| tree | 0367ad4b2449d64911deb97fb658aa0253dc4aba /llvm/lib/Analysis/ValueTracking.cpp | |
| parent | 4d37d9979857744d6bf306e8d90abb07209fea49 (diff) | |
| download | llvm-83791ced7ba2a2d43d37bb1350f28ddf83c029f9.zip llvm-83791ced7ba2a2d43d37bb1350f28ddf83c029f9.tar.gz llvm-83791ced7ba2a2d43d37bb1350f28ddf83c029f9.tar.bz2 | |
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.
llvm-svn: 131884
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
| -rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 7b7e39f..4f3dc7a 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -131,8 +131,18 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask, } return; } + + if (Argument *A = dyn_cast<Argument>(V)) { + // Get alignment information off byval arguments if specified in the IR. + if (A->hasByValAttr()) + if (unsigned Align = A->getParamAlignment()) + KnownZero = Mask & APInt::getLowBitsSet(BitWidth, + CountTrailingZeros_32(Align)); + return; + } - KnownZero.clearAllBits(); KnownOne.clearAllBits(); // Start out not knowing anything. + // Start out not knowing anything. + KnownZero.clearAllBits(); KnownOne.clearAllBits(); if (Depth == MaxDepth || Mask == 0) return; // Limit search depth. |
