summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Instruction.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-08-25 22:11:20 +0000
committerDan Gohman <gohman@apple.com>2009-08-25 22:11:20 +0000
commitc8a27f2a5c673970ac1edf8e6101c27d4dafb9a7 (patch)
treef5eaebfd8d78310f18a9fb543ccb37adeecb0ef5 /llvm/lib/VMCore/Instruction.cpp
parent76d824f3f93258039b42a3711347cdc4d27177bd (diff)
downloadbcm5719-llvm-c8a27f2a5c673970ac1edf8e6101c27d4dafb9a7.tar.gz
bcm5719-llvm-c8a27f2a5c673970ac1edf8e6101c27d4dafb9a7.zip
Rename Instruction::isIdenticalTo to Instruction::isIdenticalToWhenDefined,
and introduce a new Instruction::isIdenticalTo which tests for full identity, including the SubclassOptionalData flags. Also, fix the Instruction::clone implementations to preserve the SubclassOptionalData flags. Finally, teach several optimizations how to handle SubclassOptionalData correctly, given these changes. This fixes the counterintuitive behavior of isIdenticalTo not comparing the full value, and clone not returning an identical clone, as well as some subtle bugs that could be caused by these. Thanks to Nick Lewycky for reporting this, and for an initial patch! llvm-svn: 80038
Diffstat (limited to 'llvm/lib/VMCore/Instruction.cpp')
-rw-r--r--llvm/lib/VMCore/Instruction.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Instruction.cpp b/llvm/lib/VMCore/Instruction.cpp
index e19ad1c16f9..332ecf9782d 100644
--- a/llvm/lib/VMCore/Instruction.cpp
+++ b/llvm/lib/VMCore/Instruction.cpp
@@ -168,6 +168,14 @@ const char *Instruction::getOpcodeName(unsigned OpCode) {
/// identical to the current one. This means that all operands match and any
/// extra information (e.g. load is volatile) agree.
bool Instruction::isIdenticalTo(const Instruction *I) const {
+ return isIdenticalTo(I) &&
+ SubclassOptionalData == I->SubclassOptionalData;
+}
+
+/// isIdenticalToWenDefined - This is like isIdenticalTo, except that it
+/// ignores the SubclassOptionalData flags, which specify conditions
+/// under which the instruction's result is undefined.
+bool Instruction::isIdenticalToWhenDefined(const Instruction *I) const {
if (getOpcode() != I->getOpcode() ||
getNumOperands() != I->getNumOperands() ||
getType() != I->getType())
OpenPOWER on IntegriCloud