Fix isArrayAllocation() to be correct
authorChris Lattner <sabre@nondot.org>
Tue, 19 Feb 2002 21:24:17 +0000 (21:24 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 19 Feb 2002 21:24:17 +0000 (21:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1779 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/iMemory.h
lib/VMCore/iMemory.cpp

index 13b1400d3a3f031cdfed77e98ba4a8f518853ec5..ec04b281dbc6e3b861dece8364e9db271eded5a9 100644 (file)
@@ -35,9 +35,9 @@ public:
   }
 
   // isArrayAllocation - Return true if there is an allocation size parameter
-  // to the allocation instruction.
+  // to the allocation instruction that is not 1.
   //
-  inline bool isArrayAllocation() const { return Operands.size() == 1; }
+  bool isArrayAllocation() const;
 
   inline const Value *getArraySize() const {
     assert(isArrayAllocation()); return Operands[0];
index 4226a69615750a96e3d86ef5b9fb4607f1df56d3..7280998a17daf80bbf563cd9de85544c4b8f94f0 100644 (file)
@@ -5,12 +5,18 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/iMemory.h"
+#include "llvm/ConstantVals.h"
 
 static inline const Type *checkType(const Type *Ty) {
   assert(Ty && "Invalid indices for type!");
   return Ty;
 }
 
+bool AllocationInst::isArrayAllocation() const {
+  return getNumOperands() == 1 &&
+         getOperand(0) != ConstantUInt::get(Type::UIntTy, 1);
+}
+
 //===----------------------------------------------------------------------===//
 //                        MemAccessInst Implementation
 //===----------------------------------------------------------------------===//