mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-22 04:05:05 +00:00
Move the GET_SIDE_EFFECT_INFO logic from isInstructionTriviallyDead
to Instruction::mayWriteToMemory, fixing a FIXME, and helping various places that call mayWriteToMemory directly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40533 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c2dfd066c0
commit
37f3ee17d2
@ -175,13 +175,6 @@ bool llvm::isInstructionTriviallyDead(Instruction *I) {
|
|||||||
|
|
||||||
if (!I->mayWriteToMemory()) return true;
|
if (!I->mayWriteToMemory()) return true;
|
||||||
|
|
||||||
if (CallInst *CI = dyn_cast<CallInst>(I))
|
|
||||||
if (Function *F = CI->getCalledFunction()) {
|
|
||||||
unsigned IntrinsicID = F->getIntrinsicID();
|
|
||||||
#define GET_SIDE_EFFECT_INFO
|
|
||||||
#include "llvm/Intrinsics.gen"
|
|
||||||
#undef GET_SIDE_EFFECT_INFO
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,6 +197,15 @@ bool Instruction::isSameOperationAs(Instruction *I) const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IntrinsicOnlyReadsMemory - Return true if the specified intrinsic doesn't
|
||||||
|
// have any side-effects or if it only reads memory.
|
||||||
|
static bool IntrinsicOnlyReadsMemory(unsigned IntrinsicID) {
|
||||||
|
#define GET_SIDE_EFFECT_INFO
|
||||||
|
#include "llvm/Intrinsics.gen"
|
||||||
|
#undef GET_SIDE_EFFECT_INFO
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// mayWriteToMemory - Return true if this instruction may modify memory.
|
/// mayWriteToMemory - Return true if this instruction may modify memory.
|
||||||
///
|
///
|
||||||
bool Instruction::mayWriteToMemory() const {
|
bool Instruction::mayWriteToMemory() const {
|
||||||
@ -208,11 +217,10 @@ bool Instruction::mayWriteToMemory() const {
|
|||||||
case Instruction::VAArg:
|
case Instruction::VAArg:
|
||||||
return true;
|
return true;
|
||||||
case Instruction::Call:
|
case Instruction::Call:
|
||||||
//if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(this)) {
|
if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(this)) {
|
||||||
// If the intrinsic doesn't write memory, it is safe.
|
// If the intrinsic doesn't write memory, it is safe.
|
||||||
// FIXME: this is obviously supposed to determine which intrinsics
|
return !IntrinsicOnlyReadsMemory(II->getIntrinsicID());
|
||||||
// don't write to memory, but hasn't been implemented yet.
|
}
|
||||||
//}
|
|
||||||
return true;
|
return true;
|
||||||
case Instruction::Load:
|
case Instruction::Load:
|
||||||
return cast<LoadInst>(this)->isVolatile();
|
return cast<LoadInst>(this)->isVolatile();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user