diff options
Diffstat (limited to 'lib/IR/DataLayout.cpp')
| -rw-r--r-- | lib/IR/DataLayout.cpp | 13 | 
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/IR/DataLayout.cpp b/lib/IR/DataLayout.cpp index 4d867efe1b3d..5468f47bbfe6 100644 --- a/lib/IR/DataLayout.cpp +++ b/lib/IR/DataLayout.cpp @@ -41,6 +41,7 @@ StructLayout::StructLayout(StructType *ST, const DataLayout &DL) {    assert(!ST->isOpaque() && "Cannot get layout of opaque structs");    StructAlignment = 0;    StructSize = 0; +  IsPadded = false;    NumElements = ST->getNumElements();    // Loop over each of the elements, placing them in memory. @@ -49,8 +50,10 @@ StructLayout::StructLayout(StructType *ST, const DataLayout &DL) {      unsigned TyAlign = ST->isPacked() ? 1 : DL.getABITypeAlignment(Ty);      // Add padding if necessary to align the data element properly. -    if ((StructSize & (TyAlign-1)) != 0) +    if ((StructSize & (TyAlign-1)) != 0) { +      IsPadded = true;        StructSize = RoundUpToAlignment(StructSize, TyAlign); +    }      // Keep track of maximum alignment constraint.      StructAlignment = std::max(TyAlign, StructAlignment); @@ -64,8 +67,10 @@ StructLayout::StructLayout(StructType *ST, const DataLayout &DL) {    // Add padding to the end of the struct so that it could be put in an array    // and all array elements would be aligned correctly. -  if ((StructSize & (StructAlignment-1)) != 0) +  if ((StructSize & (StructAlignment-1)) != 0) { +    IsPadded = true;      StructSize = RoundUpToAlignment(StructSize, StructAlignment); +  }  } @@ -461,8 +466,8 @@ unsigned DataLayout::getAlignmentInfo(AlignTypeEnum AlignType,        return ABIInfo ? Alignments[i].ABIAlign : Alignments[i].PrefAlign;      // The best match so far depends on what we're looking for. -     if (AlignType == INTEGER_ALIGN && -         Alignments[i].AlignType == INTEGER_ALIGN) { +    if (AlignType == INTEGER_ALIGN && +        Alignments[i].AlignType == INTEGER_ALIGN) {        // The "best match" for integers is the smallest size that is larger than        // the BitWidth requested.        if (Alignments[i].TypeBitWidth > BitWidth && (BestMatchIdx == -1 ||  | 
