From fae098a56b403e91affcb44de7e981fc9f34ea12 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 26 Jun 2004 19:40:40 +0000 Subject: Don't call getValueType directly. the LLVM optimizer will turn it into the same code anyway :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14426 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/AsmWriter.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'lib/VMCore') diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 3ad9ecc..60589ba 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; } -- cgit v1.1