[llvm-commits] [llvm-gcc-4.2] r54427 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Dale Johannesen
dalej at apple.com
Wed Aug 6 15:53:18 PDT 2008
On Aug 6, 2008, at 3:17 PMPDT, Bill Wendling wrote:
> Author: void
> Date: Wed Aug 6 17:17:23 2008
> New Revision: 54427
>
> URL: http://llvm.org/viewvc/llvm-project?rev=54427&view=rev
> Log:
> r50318 looks like it never made it into mainline:
It was reverted later. Leave it alone.
>
> Initialize padding bytes.
>
> 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=54427&r1=54426&r2=54427&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
> +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Aug 6 17:17:23 2008
> @@ -6687,6 +6687,8 @@
>
> Constant *TreeConstantToLLVM::ConvertRecordCONSTRUCTOR(tree exp) {
> const StructType *STy =
> cast<StructType>(ConvertType(TREE_TYPE(exp)));
> +
> + bool OneEltIsUnion = false;
> std::vector<Constant*> ResultElts;
> ResultElts.resize(STy->getNumElements());
>
> @@ -6706,6 +6708,9 @@
> }
> }
>
> + if (TREE_CODE(TREE_TYPE(elt_value)) == UNION_TYPE)
> + OneEltIsUnion = true;
> +
> // Decode the field's value.
> Constant *Val = Convert(elt_value);
>
> @@ -6746,9 +6751,30 @@
> }
>
> // Fill in null elements with zeros.
> + unsigned InitSize = 0;
> for (unsigned i = 0, e = ResultElts.size(); i != e; ++i) {
> if (ResultElts[i] == 0)
> ResultElts[i] = Constant::getNullValue(STy->getElementType(i));
> +
> + InitSize += getTargetData().getABITypeSize(ResultElts[i]-
> >getType());
> + }
> +
> + // If the struct has a fixed size, and if one the union value we
> converted
> + // isn't large enough to fill all the bits, add a zero
> initialized array at
> + // the end to pad it out.
> + tree StructType = TREE_TYPE(exp);
> + if (OneEltIsUnion &&
> + TYPE_SIZE(StructType) && TREE_CODE(TYPE_SIZE(StructType)) ==
> INTEGER_CST) {
> + unsigned StructSize =
> ((unsigned)TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(exp)))+7)/8;
> + if (StructSize != InitSize) {
> + const Type *FillTy;
> + assert(StructSize > InitSize && "Init shouldn't be larger
> than struct!");
> + if (StructSize - InitSize == 1)
> + FillTy = Type::Int8Ty;
> + else
> + FillTy = ArrayType::get(Type::Int8Ty, StructSize - InitSize);
> + ResultElts.push_back(Constant::getNullValue(FillTy));
> + }
> }
>
> return ConstantStruct::get(ResultElts, STy->isPacked());
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list