diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 3ad9ecc098a..60589ba7f10 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -1163,16 +1163,18 @@ CachedWriter::~CachedWriter() { CachedWriter &CachedWriter::operator<<(const Value *V) { assert(AW && SC && "CachedWriter does not have a current module!"); - switch (V->getValueType()) { - case Value::ConstantVal: - case Value::ArgumentVal: AW->writeOperand(V, true, true); break; - case Value::TypeVal: AW->write(cast(V)); break; - case Value::InstructionVal: AW->write(cast(V)); break; - case Value::BasicBlockVal: AW->write(cast(V)); break; - case Value::FunctionVal: AW->write(cast(V)); break; - case Value::GlobalVariableVal: AW->write(cast(V)); break; - default: Out << "getValueType() << '>'; break; - } + if (const Instruction *I = dyn_cast(V)) + AW->write(I); + else if (const BasicBlock *BB = dyn_cast(V)) + AW->write(BB); + else if (const Function *F = dyn_cast(V)) + AW->write(F); + else if (const GlobalVariable *GV = dyn_cast(V)) + AW->write(GV); + else if (const Type *Ty = dyn_cast(V)) + AW->write(Ty); + else + AW->writeOperand(V, true, true); return *this; }