[llvm-commits] [llvm-gcc-4.2] r92108 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Dale Johannesen
dalej at apple.com
Wed Dec 23 17:08:33 PST 2009
Author: johannes
Date: Wed Dec 23 19:08:32 2009
New Revision: 92108
URL: http://llvm.org/viewvc/llvm-project?rev=92108&view=rev
Log:
In some cases gcc builds a MODIFY_EXPR whose RHS
is smaller than its LHS. Extend RHS in this case;
all the bits of LHS must be stored into, otherwise
they may be used uninitialized later.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=92108&r1=92107&r2=92108&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Dec 23 19:08:32 2009
@@ -2939,9 +2939,13 @@
if (ValTy->isSingleValueType()) {
// Non-bitfield, scalar value. Just emit a store.
Value *RHS = Emit(rhs, 0);
- // Convert RHS to the right type if we can, otherwise convert the pointer.
+ // Convert RHS to the right type if we can. If LHS is bigger than RHS
+ // we must convert; all the bits of LHS must be stored into. Otherwise
+ // convert the pointer.
const PointerType *PT = cast<PointerType>(LV.Ptr->getType());
- if (PT->getElementType()->canLosslesslyBitCastTo(RHS->getType()))
+ if (PT->getElementType()->canLosslesslyBitCastTo(RHS->getType()) ||
+ (PT->getElementType()->getPrimitiveSizeInBits() >
+ RHS->getType()->getPrimitiveSizeInBits()))
RHS = CastToAnyType(RHS, RHSSigned, PT->getElementType(), LHSSigned);
else
LV.Ptr = BitCastToType(LV.Ptr, RHS->getType()->getPointerTo());
More information about the llvm-commits
mailing list