From: Chris Lattner Date: Sat, 13 Apr 2002 18:34:38 +0000 (+0000) Subject: * Clean up code to use isa & dyncast instead of poking directly into instructions X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=94dc1f29cd1dc669680b7d3caa1f59862a656b83;p=oota-llvm.git * Clean up code to use isa & dyncast instead of poking directly into instructions * Do not print the allocation size for a non array allocation (this used to work, but was broken). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2235 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index f5e0fcfa922..aa11d81f27e 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -508,14 +508,14 @@ void AssemblyWriter::printInstruction(const Instruction *I) { const Value *Operand = I->getNumOperands() ? I->getOperand(0) : 0; // Special case conditional branches to swizzle the condition out to the front - if (I->getOpcode() == Instruction::Br && I->getNumOperands() > 1) { + if (isa(I) && I->getNumOperands() > 1) { writeOperand(I->getOperand(2), true); Out << ","; writeOperand(Operand, true); Out << ","; writeOperand(I->getOperand(1), true); - } else if (I->getOpcode() == Instruction::Switch) { + } else if (isa(I)) { // Special case switch statement to get formatting nice and correct... writeOperand(Operand , true); Out << ","; writeOperand(I->getOperand(1), true); Out << " ["; @@ -548,8 +548,9 @@ void AssemblyWriter::printInstruction(const Instruction *I) { // only do this if the first argument is a pointer to a nonvararg function, // and if the value returned is not a pointer to a function. // - if (RetTy && !MTy->isVarArg() && - (!isa(RetTy)||!isa(cast(RetTy)))){ + if (RetTy && MTy && !MTy->isVarArg() && + (!isa(RetTy) || + !isa(cast(RetTy)))) { Out << " "; printType(RetTy); writeOperand(Operand, false); } else { @@ -578,13 +579,12 @@ void AssemblyWriter::printInstruction(const Instruction *I) { Out << " except"; writeOperand(II->getExceptionalDest(), true); - } else if (I->getOpcode() == Instruction::Malloc || - I->getOpcode() == Instruction::Alloca) { + } else if (const AllocationInst *AI = dyn_cast(I)) { Out << " "; - printType(cast(I->getType())->getElementType()); - if (I->getNumOperands()) { + printType(AI->getType()->getElementType()); + if (AI->isArrayAllocation()) { Out << ","; - writeOperand(I->getOperand(0), true); + writeOperand(AI->getArraySize(), true); } } else if (isa(I)) { writeOperand(Operand, true);