diff options
author | Pete Cooper <peter_cooper@apple.com> | 2015-06-24 20:22:23 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2015-06-24 20:22:23 +0000 |
commit | f79d253a3ea33ce7242d22c1e9965c13fde32340 (patch) | |
tree | 4ba8896cd47b9426bed043f944003ea8a5a4cd6a /lib/IR/Instruction.cpp | |
parent | 58f8a138a9db8ef45f1061cc81e9bf2ab541cbb0 (diff) |
Devirtualize Instruction::clone_impl
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240588 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/Instruction.cpp')
-rw-r--r-- | lib/IR/Instruction.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/IR/Instruction.cpp b/lib/IR/Instruction.cpp index af426387be7..c57ba16cf6c 100644 --- a/lib/IR/Instruction.cpp +++ b/lib/IR/Instruction.cpp @@ -534,8 +534,23 @@ bool Instruction::isNilpotent(unsigned Opcode) { return Opcode == Xor; } +Instruction *Instruction::cloneImpl() const { + llvm_unreachable("Subclass of Instruction failed to implement cloneImpl"); +} + Instruction *Instruction::clone() const { - Instruction *New = clone_impl(); + Instruction *New = nullptr; + switch (getOpcode()) { + default: + llvm_unreachable("Unhandled Opcode."); +#define HANDLE_INST(num, opc, clas) \ + case Instruction::opc: \ + New = cast<clas>(this)->cloneImpl(); \ + break; +#include "llvm/IR/Instruction.def" +#undef HANDLE_INST + } + New->SubclassOptionalData = SubclassOptionalData; if (!hasMetadata()) return New; |