Add two asserts that Duncan thought would help ensure things don't rot
authorChandler Carruth <chandlerc@gmail.com>
Fri, 14 Sep 2012 10:26:34 +0000 (10:26 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 14 Sep 2012 10:26:34 +0000 (10:26 +0000)
unexpectedly in the future. More fixes from his code review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163891 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/SROA.cpp

index be7839e4c3624608c1a7f00f52db368b9c9c926f..44ffb02552cf2cc4c837f19a207f02d4eb3a7668 100644 (file)
@@ -567,6 +567,7 @@ private:
 
 
   bool visitMemSetInst(MemSetInst &II) {
+    assert(II.getRawDest() == *U && "Pointer use is not the destination?");
     ConstantInt *Length = dyn_cast<ConstantInt>(II.getLength());
     insertUse(II, Length ? Length->getZExtValue() : AllocSize - Offset, Length);
     return true;
@@ -2440,6 +2441,7 @@ bool SROA::rewriteAllocaPartition(AllocaInst &AI,
     AllocaTy = Type::getIntNTy(*C, AllocaSize * 8);
   if (!AllocaTy)
     AllocaTy = ArrayType::get(Type::getInt8Ty(*C), AllocaSize);
+  assert(TD->getTypeAllocSize(AllocaTy) >= AllocaSize);
 
   // Check for the case where we're going to rewrite to a new alloca of the
   // exact same type as the original, and with the same access offsets. In that