[llvm-commits] [dragonegg] r150476 - in /dragonegg/trunk: include/dragonegg/ABI.h include/dragonegg/ADT/IntervalList.h include/dragonegg/Internals.h src/Types.cpp

Duncan Sands baldrick at free.fr
Tue Feb 14 05:06:18 PST 2012


Author: baldrick
Date: Tue Feb 14 07:06:18 2012
New Revision: 150476

URL: http://llvm.org/viewvc/llvm-project?rev=150476&view=rev
Log:
Be explicit about 64 bit to 32 bit conversions when we really
meant to do this.

Modified:
    dragonegg/trunk/include/dragonegg/ABI.h
    dragonegg/trunk/include/dragonegg/ADT/IntervalList.h
    dragonegg/trunk/include/dragonegg/Internals.h
    dragonegg/trunk/src/Types.cpp

Modified: dragonegg/trunk/include/dragonegg/ABI.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/ABI.h?rev=150476&r1=150475&r2=150476&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/ABI.h (original)
+++ dragonegg/trunk/include/dragonegg/ABI.h Tue Feb 14 07:06:18 2012
@@ -150,7 +150,7 @@
 static inline
 Type* getLLVMScalarTypeForStructReturn(tree_node *type, unsigned *Offset) {
   Type *Ty = ConvertType(type);
-  unsigned Size = getTargetData().getTypeAllocSize(Ty);
+  uint64_t Size = getTargetData().getTypeAllocSize(Ty);
   *Offset = 0;
   if (Size == 0)
     return Type::getVoidTy(getGlobalContext());

Modified: dragonegg/trunk/include/dragonegg/ADT/IntervalList.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/ADT/IntervalList.h?rev=150476&r1=150475&r2=150476&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/ADT/IntervalList.h (original)
+++ dragonegg/trunk/include/dragonegg/ADT/IntervalList.h Tue Feb 14 07:06:18 2012
@@ -57,7 +57,9 @@
   /// isSane - Return true if the intervals are non-empty, disjoint and
   /// sorted.
   bool isSane() const {
-    for (unsigned i = 0, e = Intervals.size(); i < e; ++i) {
+    if (Intervals.size() != (unsigned)Intervals.size())
+      return false; // Too many intervals.
+    for (unsigned i = 0, e = (unsigned)Intervals.size(); i < e; ++i) {
       if (Intervals[i].getRange().empty())
         return false;
       if (i && Intervals[i].getRange().getFirst() <
@@ -77,7 +79,7 @@
 
   /// getNumIntervals - Return the number of intervals in the list.
   unsigned getNumIntervals() const {
-    return Intervals.size();
+    return (unsigned)Intervals.size();
   }
 
   /// getInterval - Return the interval with the given index.

Modified: dragonegg/trunk/include/dragonegg/Internals.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=150476&r1=150475&r2=150476&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Internals.h (original)
+++ dragonegg/trunk/include/dragonegg/Internals.h Tue Feb 14 07:06:18 2012
@@ -194,9 +194,7 @@
 public:
   explicit MemRef() : Ptr(0), Volatile(false), LogAlign(0) {}
   explicit MemRef(Value *P, uint32_t A, bool V) : Ptr(P), Volatile(V) {
-    // Forbid alignment 0 along with non-power-of-2 alignment values.
-    assert(isPowerOf2_32(A) && "Alignment not a power of 2!");
-    LogAlign = Log2_32(A);
+    setAlignment(A);
   }
 
   uint32_t getAlignment() const {
@@ -204,7 +202,9 @@
   }
 
   void setAlignment(uint32_t A) {
-    LogAlign = Log2_32(A);
+    // Forbid alignment 0 along with non-power-of-2 alignment values.
+    assert(isPowerOf2_32(A) && "Alignment not a power of 2!");
+    LogAlign = (unsigned char)Log2_32(A);
   }
 };
 
@@ -225,7 +225,8 @@
   LValue(Value *P, uint32_t A, bool V = false) :
       MemRef(P, A, V), BitStart(255), BitSize(255) {}
   LValue(Value *P, uint32_t A, unsigned BSt, unsigned BSi, bool V = false) :
-      MemRef(P, A, V), BitStart(BSt), BitSize(BSi) {
+      MemRef(P, A, V), BitStart((unsigned char)BSt),
+      BitSize((unsigned char)BSi) {
     assert(BitStart == BSt && BitSize == BSi &&
            "Bit values larger than 256?");
   }

Modified: dragonegg/trunk/src/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=150476&r1=150475&r2=150476&view=diff
==============================================================================
--- dragonegg/trunk/src/Types.cpp (original)
+++ dragonegg/trunk/src/Types.cpp Tue Feb 14 07:06:18 2012
@@ -206,7 +206,7 @@
   // Bail out if the array has variable or unknown length.
   if (!isInt64(range, false))
     return NO_LENGTH;
-  int64_t Range = getInt64(range, false);
+  int64_t Range = (int64_t)getInt64(range, false);
   return Range < 0 ? 0 : 1 + (uint64_t)Range;
 }
 
@@ -1291,7 +1291,7 @@
   // (SCC) of the type graph.  This should always be the case because SCCs are
   // visited bottom up.
   bool inSCC = false;
-  for (unsigned i = 0, e = SCCInProgress->size(); i != e; ++i)
+  for (size_t i = 0, e = SCCInProgress->size(); i != e; ++i)
     if ((*SCCInProgress)[i] == type) {
       inSCC = true;
       break;
@@ -1545,7 +1545,7 @@
     // in the SCC.  This way, if we have both "struct S" and "struct S*" in the
     // SCC then we can return an LLVM "%struct.s*" for the pointer rather than
     // the nasty {}* type we are obliged to return in general.
-    for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
+    for (size_t i = 0, e = SCC.size(); i != e; ++i) {
       tree some_type = SCC[i];
       if (TREE_CODE(some_type) != QUAL_UNION_TYPE &&
           TREE_CODE(some_type) != RECORD_TYPE &&
@@ -1578,7 +1578,7 @@
     // edges like this destroys all cycles allowing the other types in the SCC
     // to be converted straightforwardly.
     SCCInProgress = &SCC;
-    for (unsigned i = 0, e = SCC.size(); i != e; ++i)
+    for (size_t i = 0, e = SCC.size(); i != e; ++i)
       ConvertType(SCC[i]);
     SCCInProgress = 0;
 
@@ -1588,7 +1588,7 @@
     // uses by types outside the SCC will see a sensible pointer type.  This is
     // not needed for correctness - it just makes the IR nicer.
     if (SCC.size() > 1)
-      for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
+      for (size_t i = 0, e = SCC.size(); i != e; ++i) {
         tree some_type = SCC[i];
         if (POINTER_TYPE_P(some_type)) {
           tree pointee = TYPE_MAIN_VARIANT(TREE_TYPE(some_type));





More information about the llvm-commits mailing list