aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-06-26 19:40:40 +0000
committerChris Lattner <sabre@nondot.org>2004-06-26 19:40:40 +0000
commitfae098a56b403e91affcb44de7e981fc9f34ea12 (patch)
treef818b61c606336eec3a188ee96cdd69b4762ef4c /lib/VMCore
parent098648af6a8bbb42823f18bf1d3f96afc163e55f (diff)
downloadexternal_llvm-fae098a56b403e91affcb44de7e981fc9f34ea12.zip
external_llvm-fae098a56b403e91affcb44de7e981fc9f34ea12.tar.gz
external_llvm-fae098a56b403e91affcb44de7e981fc9f34ea12.tar.bz2
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
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/AsmWriter.cpp22
1 files changed, 12 insertions, 10 deletions
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<Type>(V)); break;
- case Value::InstructionVal: AW->write(cast<Instruction>(V)); break;
- case Value::BasicBlockVal: AW->write(cast<BasicBlock>(V)); break;
- case Value::FunctionVal: AW->write(cast<Function>(V)); break;
- case Value::GlobalVariableVal: AW->write(cast<GlobalVariable>(V)); break;
- default: Out << "<unknown value type: " << V->getValueType() << '>'; break;
- }
+ if (const Instruction *I = dyn_cast<Instruction>(V))
+ AW->write(I);
+ else if (const BasicBlock *BB = dyn_cast<BasicBlock>(V))
+ AW->write(BB);
+ else if (const Function *F = dyn_cast<Function>(V))
+ AW->write(F);
+ else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V))
+ AW->write(GV);
+ else if (const Type *Ty = dyn_cast<Type>(V))
+ AW->write(Ty);
+ else
+ AW->writeOperand(V, true, true);
return *this;
}