[PATCH] D82892: Added comparision for all types in haveSameSpecialState() of Instruction.cpp
Vishal Chebrolu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 30 10:50:21 PDT 2020
vish99 created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D82892
Files:
llvm/lib/IR/Instruction.cpp
Index: llvm/lib/IR/Instruction.cpp
===================================================================
--- llvm/lib/IR/Instruction.cpp
+++ llvm/lib/IR/Instruction.cpp
@@ -408,6 +408,9 @@
bool IgnoreAlignment = false) {
assert(I1->getOpcode() == I2->getOpcode() &&
"Can not compare special state of different instructions");
+ assert(I1->getNumOperands() == I2->getNumOperands() &&
+ "Can not compare special state of instructions with different number "
+ "of operands");
if (const AllocaInst *AI = dyn_cast<AllocaInst>(I1))
return AI->getAllocatedType() == cast<AllocaInst>(I2)->getAllocatedType() &&
@@ -464,8 +467,59 @@
if (const ShuffleVectorInst *SVI = dyn_cast<ShuffleVectorInst>(I1))
return SVI->getShuffleMask() ==
cast<ShuffleVectorInst>(I2)->getShuffleMask();
-
- return true;
+ if (const ReturnInst *RI = dyn_cast<ReturnInst>(I1)) {
+ if (RI->getReturnValue() != nullptr)
+ return RI->getReturnValue()->getType() ==
+ cast<ReturnInst>(I2)->getReturnValue()->getType();
+ else
+ return cast<ReturnInst>(I2)->getReturnValue() == nullptr;
+ }
+ if (const BranchInst *BI = dyn_cast<BranchInst>(I1))
+ return BI->isConditional() == cast<BranchInst>(I2)->isConditional();
+ if (const SwitchInst *SI = dyn_cast<SwitchInst>(I1))
+ return SI->getCondition()->getType() ==
+ cast<SwitchInst>(I2)->getCondition()->getType();
+ if (const IndirectBrInst *IBI = dyn_cast<IndirectBrInst>(I1))
+ return true;
+ if (const ResumeInst *RI = dyn_cast<ResumeInst>(I1))
+ return RI->getValue()->getType() ==
+ cast<ResumeInst>(I2)->getValue()->getType();
+ if (const CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(I1))
+ return CSI->unwindsToCaller() ==
+ cast<CatchSwitchInst>(I2)->unwindsToCaller();
+ if (const CatchReturnInst *CRI = dyn_cast<CatchReturnInst>(I1))
+ return true;
+ if (const CleanupReturnInst *CRI = dyn_cast<CleanupReturnInst>(I1))
+ return CRI->unwindsToCaller() ==
+ cast<CleanupReturnInst>(I2)->unwindsToCaller();
+ if (const UnreachableInst *UI = dyn_cast<UnreachableInst>(I1))
+ return true;
+ if (const UnaryOperator *UI = dyn_cast<UnaryOperator>(I1))
+ return true;
+ if (const BinaryOperator *BI = dyn_cast<BinaryOperator>(I1))
+ return true;
+ if (const GetElementPtrInst *GEP1 = dyn_cast<GetElementPtrInst>(I1))
+ return GEP1->isInBounds() == cast<GetElementPtrInst>(I2)->isInBounds();
+ if (const CastInst *CI = dyn_cast<CastInst>(I1))
+ return true;
+ if (const CleanupPadInst *CI = dyn_cast<CleanupPadInst>(I1))
+ return true;
+ if (const CatchPadInst *CPI = dyn_cast<CatchPadInst>(I1))
+ return haveSameSpecialState(CPI->getCatchSwitch(),
+ cast<CatchPadInst>(I2)->getCatchSwitch());
+ if (const PHINode *PI = dyn_cast<PHINode>(I1))
+ return true;
+ if (const SelectInst *SI = dyn_cast<SelectInst>(I1))
+ return true;
+ if (const VAArgInst *VI = dyn_cast<VAArgInst>(I1))
+ return true;
+ if (const ExtractElementInst *EI = dyn_cast<ExtractElementInst>(I1))
+ return true;
+ if (const InsertElementInst *II = dyn_cast<InsertElementInst>(I1))
+ return true;
+ if (const LandingPadInst *LI = dyn_cast<LandingPadInst>(I1))
+ return LI->isCleanup() == cast<LandingPadInst>(I2)->isCleanup();
+ llvm_unreachable("Instructions to compare are unknown");
}
bool Instruction::isIdenticalTo(const Instruction *I) const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82892.274533.patch
Type: text/x-patch
Size: 3516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200630/0879c8e1/attachment.bin>
More information about the llvm-commits
mailing list