From cbb70ce070d220642b038ea101d9c0f9fbf860d6 Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 20 Feb 2011 12:57:14 +0000 Subject: Vendor import of llvm trunk r126079: http://llvm.org/svn/llvm-project/llvm/trunk@126079 --- lib/VMCore/Instruction.cpp | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) (limited to 'lib/VMCore/Instruction.cpp') diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index 05bed4c..2c8b8b2 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -200,12 +200,10 @@ bool Instruction::isIdenticalToWhenDefined(const Instruction *I) const { if (const CallInst *CI = dyn_cast(this)) return CI->isTailCall() == cast(I)->isTailCall() && CI->getCallingConv() == cast(I)->getCallingConv() && - CI->getAttributes().getRawPointer() == - cast(I)->getAttributes().getRawPointer(); + CI->getAttributes() == cast(I)->getAttributes(); if (const InvokeInst *CI = dyn_cast(this)) return CI->getCallingConv() == cast(I)->getCallingConv() && - CI->getAttributes().getRawPointer() == - cast(I)->getAttributes().getRawPointer(); + CI->getAttributes() == cast(I)->getAttributes(); if (const InsertValueInst *IVI = dyn_cast(this)) { if (IVI->getNumIndices() != cast(I)->getNumIndices()) return false; @@ -253,12 +251,11 @@ bool Instruction::isSameOperationAs(const Instruction *I) const { if (const CallInst *CI = dyn_cast(this)) return CI->isTailCall() == cast(I)->isTailCall() && CI->getCallingConv() == cast(I)->getCallingConv() && - CI->getAttributes().getRawPointer() == - cast(I)->getAttributes().getRawPointer(); + CI->getAttributes() == cast(I)->getAttributes(); if (const InvokeInst *CI = dyn_cast(this)) return CI->getCallingConv() == cast(I)->getCallingConv() && - CI->getAttributes().getRawPointer() == - cast(I)->getAttributes().getRawPointer(); + CI->getAttributes() == + cast(I)->getAttributes(); if (const InsertValueInst *IVI = dyn_cast(this)) { if (IVI->getNumIndices() != cast(I)->getNumIndices()) return false; @@ -348,7 +345,7 @@ bool Instruction::mayThrow() const { /// /// In LLVM, the Add, Mul, And, Or, and Xor operators are associative. /// -bool Instruction::isAssociative(unsigned Opcode, const Type *Ty) { +bool Instruction::isAssociative(unsigned Opcode) { return Opcode == And || Opcode == Or || Opcode == Xor || Opcode == Add || Opcode == Mul; } @@ -398,25 +395,10 @@ bool Instruction::isSafeToSpeculativelyExecute() const { return Op && !Op->isNullValue() && !Op->isAllOnesValue(); } case Load: { - if (cast(this)->isVolatile()) + const LoadInst *LI = cast(this); + if (LI->isVolatile()) return false; - // Note that it is not safe to speculate into a malloc'd region because - // malloc may return null. - // It's also not safe to follow a bitcast, for example: - // bitcast i8* (alloca i8) to i32* - // would result in a 4-byte load from a 1-byte alloca. - Value *Op0 = getOperand(0); - if (GEPOperator *GEP = dyn_cast(Op0)) { - // TODO: it's safe to do this for any GEP with constant indices that - // compute inside the allocated type, but not for any inbounds gep. - if (GEP->hasAllZeroIndices()) - Op0 = GEP->getPointerOperand(); - } - if (isa(Op0)) - return true; - if (GlobalVariable *GV = dyn_cast(getOperand(0))) - return !GV->hasExternalWeakLinkage(); - return false; + return LI->getPointerOperand()->isDereferenceablePointer(); } case Call: return false; // The called function could have undefined behavior or -- cgit v1.1