[llvm-commits] [llvm] r124672 - /llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp

Jim Grosbach grosbach at apple.com
Thu Feb 3 15:28:37 PST 2011


Hi David,

I'm getting some build warnings from clang when compiling this. Can you take a look?

-Jim

/Volumes/Home/grosbaj/sources/llvm/utils/TableGen/CodeGenDAGPatterns.cpp:452:3: warning: 
      use of uninitialized variable 'LargestFP' [-Wuninitialized]
  MVT::SimpleValueType LargestFP;
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Home/grosbaj/sources/llvm/utils/TableGen/CodeGenDAGPatterns.cpp:459:65: note: 
      variable 'LargestFP' is possibly uninitialized when used here
    if (isFloatingPoint(Other.TypeVec[i]) && Other.TypeVec[i] > LargestFP)
                                                                ^~~~~~~~~
/Volumes/Home/grosbaj/sources/llvm/utils/TableGen/CodeGenDAGPatterns.cpp:479:19: note: 
      variable 'LargestFP' is possibly uninitialized when used here
      if (*TVI == LargestFP) {
                  ^~~~~~~~~
/Volumes/Home/grosbaj/sources/llvm/utils/TableGen/CodeGenDAGPatterns.cpp:452:33: note: 
      add initialization to silence this warning
  MVT::SimpleValueType LargestFP;
                                ^
                                 = 0
/Volumes/Home/grosbaj/sources/llvm/utils/TableGen/CodeGenDAGPatterns.cpp:386:3: warning: 
      use of uninitialized variable 'SmallestInt' [-Wuninitialized]
  MVT::SimpleValueType SmallestInt;
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Home/grosbaj/sources/llvm/utils/TableGen/CodeGenDAGPatterns.cpp:393:47: note: 
      variable 'SmallestInt' is possibly uninitialized when used here
    if (isInteger(TypeVec[i]) && TypeVec[i] < SmallestInt)
                                              ^~~~~~~~~~~
/Volumes/Home/grosbaj/sources/llvm/utils/TableGen/CodeGenDAGPatterns.cpp:414:19: note: 
      variable 'SmallestInt' is possibly uninitialized when used here
      if (*TVI == SmallestInt) {
                  ^~~~~~~~~~~
/Volumes/Home/grosbaj/sources/llvm/utils/TableGen/CodeGenDAGPatterns.cpp:386:35: note: 
      add initialization to silence this warning
  MVT::SimpleValueType SmallestInt;
                                  ^
                                   = 0
/Volumes/Home/grosbaj/sources/llvm/utils/TableGen/CodeGenDAGPatterns.cpp:396:3: warning: 
      use of uninitialized variable 'SmallestFP' [-Wuninitialized]
  MVT::SimpleValueType SmallestFP;
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Home/grosbaj/sources/llvm/utils/TableGen/CodeGenDAGPatterns.cpp:403:53: note: 
      variable 'SmallestFP' is possibly uninitialized when used here
    if (isFloatingPoint(TypeVec[i]) && TypeVec[i] < SmallestFP)
                                                    ^~~~~~~~~~
/Volumes/Home/grosbaj/sources/llvm/utils/TableGen/CodeGenDAGPatterns.cpp:423:19: note: 
      variable 'SmallestFP' is possibly uninitialized when used here
      if (*TVI == SmallestFP) {
                  ^~~~~~~~~~
/Volumes/Home/grosbaj/sources/llvm/utils/TableGen/CodeGenDAGPatterns.cpp:396:34: note: 
      add initialization to silence this warning
  MVT::SimpleValueType SmallestFP;
                                 ^
                                  = 0


On Feb 1, 2011, at 11:12 AM, David Greene wrote:

> Author: greened
> Date: Tue Feb  1 13:12:32 2011
> New Revision: 124672
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=124672&view=rev
> Log:
> 
> [AVX] Implement EnforceSmallerThan for mixed int/fp type lists.  This
> makes type checking for extract_subvector and insert_subvector more
> robust and will allow stricter typechecking of more patterns in the
> future.
> 
> This change handles int and fp as disjoint sets so that it will
> enforce integer types to be smaller than the largest integer type and
> fp types to be smaller than the largest fp type.  There is no attempt
> to check type sizes across the int/fp sets.
> 
> Modified:
>    llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
> 
> Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=124672&r1=124671&r2=124672&view=diff
> ==============================================================================
> --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
> +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Tue Feb  1 13:12:32 2011
> @@ -344,52 +344,155 @@
>   if (!hasVectorTypes())
>     MadeChange |= EnforceScalar(TP);
> 
> -  // This code does not currently handle nodes which have multiple types,
> -  // where some types are integer, and some are fp.  Assert that this is not
> -  // the case.
> -  assert(!(hasIntegerTypes() && hasFloatingPointTypes()) &&
> -         !(Other.hasIntegerTypes() && Other.hasFloatingPointTypes()) &&
> -         "SDTCisOpSmallerThanOp does not handle mixed int/fp types!");
> +  if (TypeVec.size() == 1 && Other.TypeVec.size() == 1) {
> +    // If we are down to concrete types, this code does not currently
> +    // handle nodes which have multiple types, where some types are
> +    // integer, and some are fp.  Assert that this is not the case.
> +    assert(!(hasIntegerTypes() && hasFloatingPointTypes()) &&
> +           !(Other.hasIntegerTypes() && Other.hasFloatingPointTypes()) &&
> +           "SDTCisOpSmallerThanOp does not handle mixed int/fp types!");
> +
> +    // Otherwise, if these are both vector types, either this vector
> +    // must have a larger bitsize than the other, or this element type
> +    // must be larger than the other.
> +    EVT Type(TypeVec[0]);
> +    EVT OtherType(Other.TypeVec[0]);
> +
> +    if (hasVectorTypes() && Other.hasVectorTypes()) {
> +      if (Type.getSizeInBits() >= OtherType.getSizeInBits())
> +        if (Type.getVectorElementType().getSizeInBits()
> +            >= OtherType.getVectorElementType().getSizeInBits())
> +          TP.error("Type inference contradiction found, '" +
> +                   getName() + "' element type not smaller than '" +
> +                   Other.getName() +"'!");
> +    }
> +    else
> +      // For scalar types, the bitsize of this type must be larger
> +      // than that of the other.
> +      if (Type.getSizeInBits() >= OtherType.getSizeInBits())
> +        TP.error("Type inference contradiction found, '" +
> +                 getName() + "' is not smaller than '" +
> +                 Other.getName() +"'!");
> +
> +  }
> +  
> +
> +  // Handle int and fp as disjoint sets.  This won't work for patterns
> +  // that have mixed fp/int types but those are likely rare and would
> +  // not have been accepted by this code previously.
> 
>   // Okay, find the smallest type from the current set and remove it from the
>   // largest set.
> -  MVT::SimpleValueType Smallest = TypeVec[0];
> +  MVT::SimpleValueType SmallestInt;
> +  for (unsigned i = 0, e = TypeVec.size(); i != e; ++i)
> +    if (isInteger(TypeVec[i])) {
> +      SmallestInt = TypeVec[i];
> +      break;
> +    }
> +  for (unsigned i = 1, e = TypeVec.size(); i != e; ++i)
> +    if (isInteger(TypeVec[i]) && TypeVec[i] < SmallestInt)
> +      SmallestInt = TypeVec[i];
> +
> +  MVT::SimpleValueType SmallestFP;
> +  for (unsigned i = 0, e = TypeVec.size(); i != e; ++i)
> +    if (isFloatingPoint(TypeVec[i])) {
> +      SmallestFP = TypeVec[i];
> +      break;
> +    }
>   for (unsigned i = 1, e = TypeVec.size(); i != e; ++i)
> -    if (TypeVec[i] < Smallest)
> -      Smallest = TypeVec[i];
> +    if (isFloatingPoint(TypeVec[i]) && TypeVec[i] < SmallestFP)
> +      SmallestFP = TypeVec[i];
> +
> +  int OtherIntSize = 0;
> +  int OtherFPSize = 0;
> +  for (SmallVector<MVT::SimpleValueType, 2>::iterator TVI =
> +         Other.TypeVec.begin();
> +       TVI != Other.TypeVec.end();
> +       /* NULL */) {
> +    if (isInteger(*TVI)) {
> +      ++OtherIntSize;
> +      if (*TVI == SmallestInt) {
> +        TVI = Other.TypeVec.erase(TVI);
> +        --OtherIntSize;
> +        MadeChange = true;
> +        continue;
> +      }
> +    }
> +    else if (isFloatingPoint(*TVI)) {
> +      ++OtherFPSize;
> +      if (*TVI == SmallestFP) {
> +        TVI = Other.TypeVec.erase(TVI);
> +        --OtherFPSize;
> +        MadeChange = true;
> +        continue;
> +      }
> +    }
> +    ++TVI;
> +  }
> 
>   // If this is the only type in the large set, the constraint can never be
>   // satisfied.
> -  if (Other.TypeVec.size() == 1 && Other.TypeVec[0] == Smallest)
> +  if ((Other.hasIntegerTypes() && OtherIntSize == 0)
> +      || (Other.hasFloatingPointTypes() && OtherFPSize == 0))
>     TP.error("Type inference contradiction found, '" +
>              Other.getName() + "' has nothing larger than '" + getName() +"'!");
> 
> -  SmallVector<MVT::SimpleValueType, 2>::iterator TVI =
> -    std::find(Other.TypeVec.begin(), Other.TypeVec.end(), Smallest);
> -  if (TVI != Other.TypeVec.end()) {
> -    Other.TypeVec.erase(TVI);
> -    MadeChange = true;
> -  }
> -
>   // Okay, find the largest type in the Other set and remove it from the
>   // current set.
> -  MVT::SimpleValueType Largest = Other.TypeVec[0];
> +  MVT::SimpleValueType LargestInt = Other.TypeVec[0];
> +  for (unsigned i = 0, e = Other.TypeVec.size(); i != e; ++i)
> +    if (isInteger(Other.TypeVec[i])) {
> +      LargestInt = Other.TypeVec[i];
> +      break;
> +    }
> +  for (unsigned i = 1, e = Other.TypeVec.size(); i != e; ++i)
> +    if (isInteger(Other.TypeVec[i]) && Other.TypeVec[i] > LargestInt)
> +      LargestInt = Other.TypeVec[i];
> +
> +  MVT::SimpleValueType LargestFP;
> +  for (unsigned i = 0, e = Other.TypeVec.size(); i != e; ++i)
> +    if (isFloatingPoint(Other.TypeVec[i])) {
> +      LargestFP = Other.TypeVec[i];
> +      break;
> +    }
>   for (unsigned i = 1, e = Other.TypeVec.size(); i != e; ++i)
> -    if (Other.TypeVec[i] > Largest)
> -      Largest = Other.TypeVec[i];
> +    if (isFloatingPoint(Other.TypeVec[i]) && Other.TypeVec[i] > LargestFP)
> +      LargestFP = Other.TypeVec[i];
> +
> +  int IntSize = 0;
> +  int FPSize = 0;
> +  for (SmallVector<MVT::SimpleValueType, 2>::iterator TVI =
> +         TypeVec.begin();
> +       TVI != TypeVec.end();
> +       /* NULL */) {
> +    if (isInteger(*TVI)) {
> +      ++IntSize;
> +      if (*TVI == LargestInt) {
> +        TVI = TypeVec.erase(TVI);
> +        --IntSize;
> +        MadeChange = true;
> +        continue;
> +      }
> +    }
> +    else if (isFloatingPoint(*TVI)) {
> +      ++FPSize;
> +      if (*TVI == LargestFP) {
> +        TVI = TypeVec.erase(TVI);
> +        --FPSize;
> +        MadeChange = true;
> +        continue;
> +      }
> +    }
> +    ++TVI;
> +  }
> 
>   // If this is the only type in the small set, the constraint can never be
>   // satisfied.
> -  if (TypeVec.size() == 1 && TypeVec[0] == Largest)
> +  if ((hasIntegerTypes() && IntSize == 0)
> +      || (hasFloatingPointTypes() && FPSize == 0))
>     TP.error("Type inference contradiction found, '" +
>              getName() + "' has nothing smaller than '" + Other.getName()+"'!");
> 
> -  TVI = std::find(TypeVec.begin(), TypeVec.end(), Largest);
> -  if (TVI != TypeVec.end()) {
> -    TypeVec.erase(TVI);
> -    MadeChange = true;
> -  }
> -
>   return MadeChange;
> }
> 
> 
> 
> _______________________________________________
> 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