From: Eli Friedman Date: Mon, 15 Aug 2011 21:00:18 +0000 (+0000) Subject: Fix predicates methods on Instruction to handle atomic load/store correctly. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=e5e771263a71536ab2794ae726f43e7ccd2720ac;p=oota-llvm.git Fix predicates methods on Instruction to handle atomic load/store correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137652 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index eadcd098b1f..22656f3353d 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -196,10 +196,14 @@ bool Instruction::isIdenticalToWhenDefined(const Instruction *I) const { // Check special state that is a part of some instructions. if (const LoadInst *LI = dyn_cast(this)) return LI->isVolatile() == cast(I)->isVolatile() && - LI->getAlignment() == cast(I)->getAlignment(); + LI->getAlignment() == cast(I)->getAlignment() && + LI->getOrdering() == cast(I)->getOrdering() && + LI->getSynchScope() == cast(I)->getSynchScope(); if (const StoreInst *SI = dyn_cast(this)) return SI->isVolatile() == cast(I)->isVolatile() && - SI->getAlignment() == cast(I)->getAlignment(); + SI->getAlignment() == cast(I)->getAlignment() && + SI->getOrdering() == cast(I)->getOrdering() && + SI->getSynchScope() == cast(I)->getSynchScope(); if (const CmpInst *CI = dyn_cast(this)) return CI->getPredicate() == cast(I)->getPredicate(); if (const CallInst *CI = dyn_cast(this)) @@ -247,10 +251,14 @@ bool Instruction::isSameOperationAs(const Instruction *I) const { // Check special state that is a part of some instructions. if (const LoadInst *LI = dyn_cast(this)) return LI->isVolatile() == cast(I)->isVolatile() && - LI->getAlignment() == cast(I)->getAlignment(); + LI->getAlignment() == cast(I)->getAlignment() && + LI->getOrdering() == cast(I)->getOrdering() && + LI->getSynchScope() == cast(I)->getSynchScope(); if (const StoreInst *SI = dyn_cast(this)) return SI->isVolatile() == cast(I)->isVolatile() && - SI->getAlignment() == cast(I)->getAlignment(); + SI->getAlignment() == cast(I)->getAlignment() && + SI->getOrdering() == cast(I)->getOrdering() && + SI->getSynchScope() == cast(I)->getSynchScope(); if (const CmpInst *CI = dyn_cast(this)) return CI->getPredicate() == cast(I)->getPredicate(); if (const CallInst *CI = dyn_cast(this)) @@ -318,7 +326,7 @@ bool Instruction::mayReadFromMemory() const { case Instruction::Invoke: return !cast(this)->doesNotAccessMemory(); case Instruction::Store: - return cast(this)->isVolatile(); + return !cast(this)->isUnordered(); } } @@ -338,7 +346,7 @@ bool Instruction::mayWriteToMemory() const { case Instruction::Invoke: return !cast(this)->onlyReadsMemory(); case Instruction::Load: - return cast(this)->isVolatile(); + return !cast(this)->isUnordered(); } } @@ -407,7 +415,7 @@ bool Instruction::isSafeToSpeculativelyExecute() const { } case Load: { const LoadInst *LI = cast(this); - if (LI->isVolatile()) + if (!LI->isUnordered()) return false; return LI->getPointerOperand()->isDereferenceablePointer(); }