Changes (* location in pointer variables, avoiding include, and using APInt::getLimitedValue) based on feedback to r85814

llvm-svn: 85933
This commit is contained in:
Victor Hernandez 2009-11-03 20:02:35 +00:00
parent e9d7d78ab3
commit 5cd73a3470
1 changed files with 34 additions and 39 deletions

View File

@ -16,7 +16,6 @@
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/Instructions.h" #include "llvm/Instructions.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/ADT/APInt.h"
#include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/ConstantFolding.h"
using namespace llvm; using namespace llvm;
@ -161,13 +160,9 @@ static Value* isArrayMallocHelper(const CallInst *CI, LLVMContext &Context,
if (!Op1CI) return NULL; if (!Op1CI) return NULL;
APInt Op1Int = Op1CI->getValue(); APInt Op1Int = Op1CI->getValue();
unsigned Op1Width = Op1Int.getBitWidth(); uint64_t BitToSet = Op1Int.getLimitedValue(Op1Int.getBitWidth() - 1);
// check for overflow
if (Op1Int.getActiveBits() > 64 || Op1Int.getZExtValue() > Op1Width)
return NULL;
Value *Op1Pow = ConstantInt::get(Context, Value *Op1Pow = ConstantInt::get(Context,
APInt(Op1Width, 0).set(Op1Int.getZExtValue())); APInt(Op1Int.getBitWidth(), 0).set(BitToSet));
if (Op0 == ElementSize || (FoldedElementSize && Op0 == FoldedElementSize)) if (Op0 == ElementSize || (FoldedElementSize && Op0 == FoldedElementSize))
// ArraySize << log2(ElementSize) // ArraySize << log2(ElementSize)
return Op1Pow; return Op1Pow;