diff options
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 160 | ||||
-rw-r--r-- | lib/VMCore/BasicBlock.cpp | 18 | ||||
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 80 | ||||
-rw-r--r-- | lib/VMCore/ConstantFold.h | 6 | ||||
-rw-r--r-- | lib/VMCore/ConstantFolding.h | 6 | ||||
-rw-r--r-- | lib/VMCore/ConstantRange.cpp | 14 | ||||
-rw-r--r-- | lib/VMCore/Constants.cpp | 62 | ||||
-rw-r--r-- | lib/VMCore/Dominators.cpp | 38 | ||||
-rw-r--r-- | lib/VMCore/Function.cpp | 16 | ||||
-rw-r--r-- | lib/VMCore/Globals.cpp | 16 | ||||
-rw-r--r-- | lib/VMCore/Instruction.cpp | 14 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 80 | ||||
-rw-r--r-- | lib/VMCore/LeakDetector.cpp | 4 | ||||
-rw-r--r-- | lib/VMCore/Mangler.cpp | 10 | ||||
-rw-r--r-- | lib/VMCore/Module.cpp | 10 | ||||
-rw-r--r-- | lib/VMCore/ModuleProvider.cpp | 4 | ||||
-rw-r--r-- | lib/VMCore/Pass.cpp | 20 | ||||
-rw-r--r-- | lib/VMCore/PassManagerT.h | 32 | ||||
-rw-r--r-- | lib/VMCore/SymbolTable.cpp | 22 | ||||
-rw-r--r-- | lib/VMCore/SymbolTableListTraitsImpl.h | 4 | ||||
-rw-r--r-- | lib/VMCore/Type.cpp | 96 | ||||
-rw-r--r-- | lib/VMCore/Value.cpp | 12 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 54 |
23 files changed, 389 insertions, 389 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 1049f962a4..18d045f488 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -1,10 +1,10 @@ //===-- AsmWriter.cpp - Printing LLVM as an assembly file -----------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This library implements the functionality defined in llvm/Assembly/Writer.h @@ -46,7 +46,7 @@ public: typedef std::map<const Type*, unsigned> TypeMap; /// @brief A plane with next slot number and ValueMap - struct ValuePlane { + struct ValuePlane { unsigned next_slot; ///< The next slot number to use ValueMap map; ///< The map of Value* -> unsigned ValuePlane() { next_slot = 0; } ///< Make sure we start at 0 @@ -90,15 +90,15 @@ public: /// @name Mutators /// @{ public: - /// If you'd like to deal with a function instead of just a module, use + /// If you'd like to deal with a function instead of just a module, use /// this method to get its data into the SlotMachine. - void incorporateFunction(const Function *F) { - TheFunction = F; + void incorporateFunction(const Function *F) { + TheFunction = F; FunctionProcessed = false; } - /// After calling incorporateFunction, use this method to remove the - /// most recently incorporated function from the SlotMachine. This + /// After calling incorporateFunction, use this method to remove the + /// most recently incorporated function from the SlotMachine. This /// will reset the state of the machine back to just the module contents. void purgeFunction(); @@ -109,7 +109,7 @@ private: /// This function does the actual initialization. inline void initialize(); - /// Values can be crammed into here at will. If they haven't + /// Values can be crammed into here at will. If they haven't /// been inserted already, they get inserted, otherwise they are ignored. /// Either way, the slot number for the Value* is returned. unsigned createSlot(const Value *V); @@ -117,7 +117,7 @@ private: /// Insert a value into the value table. Return the slot number /// that it now occupies. BadThings(TM) will happen if you insert a - /// Value that's already been inserted. + /// Value that's already been inserted. unsigned insertValue( const Value *V ); unsigned insertValue( const Type* Ty); @@ -162,12 +162,12 @@ X("printm", "Print module to stderr",PassInfo::Analysis|PassInfo::Optimization); static RegisterPass<PrintFunctionPass> Y("print","Print function to stderr",PassInfo::Analysis|PassInfo::Optimization); -static void WriteAsOperandInternal(std::ostream &Out, const Value *V, +static void WriteAsOperandInternal(std::ostream &Out, const Value *V, bool PrintName, std::map<const Type *, std::string> &TypeTable, SlotMachine *Machine); -static void WriteAsOperandInternal(std::ostream &Out, const Type *T, +static void WriteAsOperandInternal(std::ostream &Out, const Type *T, bool PrintName, std::map<const Type *, std::string> &TypeTable, SlotMachine *Machine); @@ -219,7 +219,7 @@ static std::string getLLVMName(const std::string &Name, C != '-' && C != '.' && C != '_') return "\"" + Name + "\""; } - + // If we get here, then the identifier is legal to use as a "VarID". if (prefixName) return "%"+Name; @@ -250,7 +250,7 @@ static void fillTypeNameTable(const Module *M, -static void calcTypeName(const Type *Ty, +static void calcTypeName(const Type *Ty, std::vector<const Type *> &TypeStack, std::map<const Type *, std::string> &TypeNames, std::string & Result){ @@ -275,7 +275,7 @@ static void calcTypeName(const Type *Ty, unsigned Slot = 0, CurSize = TypeStack.size(); while (Slot < CurSize && TypeStack[Slot] != Ty) ++Slot; // Scan for type - // This is another base case for the recursion. In this case, we know + // This is another base case for the recursion. In this case, we know // that we have looped back to a type that we have previously visited. // Generate the appropriate upreference to handle this. if (Slot < CurSize) { @@ -284,7 +284,7 @@ static void calcTypeName(const Type *Ty, } TypeStack.push_back(Ty); // Recursive case: Add us to the stack.. - + switch (Ty->getTypeID()) { case Type::FunctionTyID: { const FunctionType *FTy = cast<FunctionType>(Ty); @@ -316,7 +316,7 @@ static void calcTypeName(const Type *Ty, break; } case Type::PointerTyID: - calcTypeName(cast<PointerType>(Ty)->getElementType(), + calcTypeName(cast<PointerType>(Ty)->getElementType(), TypeStack, TypeNames, Result); Result += "*"; break; @@ -379,22 +379,22 @@ static std::ostream &printTypeInt(std::ostream &Out, const Type *Ty, /// std::ostream &llvm::WriteTypeSymbolic(std::ostream &Out, const Type *Ty, const Module *M) { - Out << ' '; + Out << ' '; // If they want us to print out a type, attempt to make it symbolic if there // is a symbol table in the module... if (M) { std::map<const Type *, std::string> TypeNames; fillTypeNameTable(M, TypeNames); - + return printTypeInt(Out, Ty, TypeNames); } else { return Out << Ty->getDescription(); } } -/// @brief Internal constant writer. -static void WriteConstantInt(std::ostream &Out, const Constant *CV, +/// @brief Internal constant writer. +static void WriteConstantInt(std::ostream &Out, const Constant *CV, bool PrintName, std::map<const Type *, std::string> &TypeTable, SlotMachine *Machine) { @@ -424,7 +424,7 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, Out << StrVal; return; } - + // Otherwise we could not reparse it to exactly the same value, so we must // output the string in hexadecimal format! // @@ -445,7 +445,7 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, } else if (const ConstantArray *CA = dyn_cast<ConstantArray>(CV)) { // As a special case, print the array as a string if it is an array of // ubytes or an array of sbytes with positive values. - // + // const Type *ETy = CA->getType()->getElementType(); bool isString = (ETy == Type::SByteTy || ETy == Type::UByteTy); @@ -459,9 +459,9 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, if (isString) { Out << "c\""; for (unsigned i = 0; i < CA->getNumOperands(); ++i) { - unsigned char C = + unsigned char C = (unsigned char)cast<ConstantInt>(CA->getOperand(i))->getRawValue(); - + if (isprint(C) && C != '"' && C != '\\') { Out << C; } else { @@ -509,7 +509,7 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, Out << " }"; } else if (const ConstantPacked *CP = dyn_cast<ConstantPacked>(CV)) { const Type *ETy = CP->getType()->getElementType(); - assert(CP->getNumOperands() > 0 && + assert(CP->getNumOperands() > 0 && "Number of operands for a PackedConst must be > 0"); Out << '<'; Out << ' '; @@ -531,14 +531,14 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) { Out << CE->getOpcodeName() << " ("; - + for (User::const_op_iterator OI=CE->op_begin(); OI != CE->op_end(); ++OI) { printTypeInt(Out, (*OI)->getType(), TypeTable); WriteAsOperandInternal(Out, *OI, PrintName, TypeTable, Machine); if (OI+1 != CE->op_end()) Out << ", "; } - + if (CE->getOpcode() == Instruction::Cast) { Out << " to "; printTypeInt(Out, CE->getType(), TypeTable); @@ -555,7 +555,7 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, /// ostream. This can be useful when you just want to print int %reg126, not /// the whole instruction that generated it. /// -static void WriteAsOperandInternal(std::ostream &Out, const Value *V, +static void WriteAsOperandInternal(std::ostream &Out, const Value *V, bool PrintName, std::map<const Type*, std::string> &TypeTable, SlotMachine *Machine) { @@ -572,7 +572,7 @@ static void WriteAsOperandInternal(std::ostream &Out, const Value *V, Slot = Machine->getSlot(V); } else { Machine = createSlotMachine(V); - if (Machine == 0) + if (Machine == 0) Slot = Machine->getSlot(V); else Slot = -1; @@ -591,7 +591,7 @@ static void WriteAsOperandInternal(std::ostream &Out, const Value *V, /// the whole instruction that generated it. /// std::ostream &llvm::WriteAsOperand(std::ostream &Out, const Value *V, - bool PrintType, bool PrintName, + bool PrintType, bool PrintName, const Module *Context) { std::map<const Type *, std::string> TypeNames; if (Context == 0) Context = getModuleFromVal(V); @@ -601,16 +601,16 @@ std::ostream &llvm::WriteAsOperand(std::ostream &Out, const Value *V, if (PrintType) printTypeInt(Out, V->getType(), TypeNames); - + WriteAsOperandInternal(Out, V, PrintName, TypeNames, 0); return Out; } -/// WriteAsOperandInternal - Write the name of the specified value out to -/// the specified ostream. This can be useful when you just want to print +/// WriteAsOperandInternal - Write the name of the specified value out to +/// the specified ostream. This can be useful when you just want to print /// int %reg126, not the whole instruction that generated it. /// -static void WriteAsOperandInternal(std::ostream &Out, const Type *T, +static void WriteAsOperandInternal(std::ostream &Out, const Type *T, bool PrintName, std::map<const Type*, std::string> &TypeTable, SlotMachine *Machine) { @@ -632,7 +632,7 @@ static void WriteAsOperandInternal(std::ostream &Out, const Type *T, /// the whole instruction that generated it. /// std::ostream &llvm::WriteAsOperand(std::ostream &Out, const Type *Ty, - bool PrintType, bool PrintName, + bool PrintType, bool PrintName, const Module *Context) { std::map<const Type *, std::string> TypeNames; assert(Context != 0 && "Can't write types as operand without module context"); @@ -641,7 +641,7 @@ std::ostream &llvm::WriteAsOperand(std::ostream &Out, const Type *Ty, // if (PrintType) // printTypeInt(Out, V->getType(), TypeNames); - + printTypeInt(Out, Ty, TypeNames); WriteAsOperandInternal(Out, Ty, PrintName, TypeNames, 0); @@ -753,7 +753,7 @@ std::ostream &AssemblyWriter::printTypeAtLeastOneLevel(const Type *Ty) { } -void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType, +void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType, bool PrintName) { if (Operand != 0) { if (PrintType) { Out << ' '; printType(Operand->getType()); } @@ -766,7 +766,7 @@ void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType, void AssemblyWriter::printModule(const Module *M) { if (!M->getModuleIdentifier().empty() && - // Don't print the ID if it will start a new line (which would + // Don't print the ID if it will start a new line (which would // require a comment char before it). M->getModuleIdentifier().find('\n') == std::string::npos) Out << "; ModuleID = '" << M->getModuleIdentifier() << "'\n"; @@ -783,7 +783,7 @@ void AssemblyWriter::printModule(const Module *M) { } if (!M->getTargetTriple().empty()) Out << "target triple = \"" << M->getTargetTriple() << "\"\n"; - + // Loop over the dependent libraries and emit them. Module::lib_iterator LI = M->lib_begin(); Module::lib_iterator LE = M->lib_end(); @@ -800,12 +800,12 @@ void AssemblyWriter::printModule(const Module *M) { // Loop over the symbol table, emitting all named constants. printSymbolTable(M->getSymbolTable()); - + for (Module::const_global_iterator I = M->global_begin(), E = M->global_end(); I != E; ++I) printGlobal(I); Out << "\nimplementation ; Functions:\n"; - + // Output all of the functions. for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) printFunction(I); @@ -814,7 +814,7 @@ void AssemblyWriter::printModule(const Module *M) { void AssemblyWriter::printGlobal(const GlobalVariable *GV) { if (GV->hasName()) Out << getLLVMName(GV->getName()) << " = "; - if (!GV->hasInitializer()) + if (!GV->hasInitializer()) Out << "external "; else switch (GV->getLinkage()) { @@ -856,7 +856,7 @@ void AssemblyWriter::printSymbolTable(const SymbolTable &ST) { // printTypeAtLeastOneLevel(TI->second) << "\n"; } - + // Print the constants, in type plane order. for (SymbolTable::plane_const_iterator PI = ST.plane_begin(); PI != ST.plane_end(); ++PI ) { @@ -940,7 +940,7 @@ void AssemblyWriter::printFunction(const Function *F) { Out << "\n"; } else { Out << " {"; - + // Output all of its basic blocks... for the function for (Function::const_iterator I = F->begin(), E = F->end(); I != E; ++I) printBasicBlock(I); @@ -960,7 +960,7 @@ void AssemblyWriter::printArgument(const Argument *Arg) { // Output type... printType(Arg->getType()); - + // Output name, if available... if (Arg->hasName()) Out << ' ' << getLLVMName(Arg->getName()); @@ -987,7 +987,7 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { // Output predecessors for the block... Out << "\t\t;"; pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB); - + if (PI == PE) { Out << " No predecessors!"; } else { @@ -1000,7 +1000,7 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { } } } - + Out << "\n"; if (AnnotationWriter) AnnotationWriter->emitBasicBlockStartAnnot(BB, Out); @@ -1080,7 +1080,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) { for (unsigned op = 0, Eop = I.getNumOperands(); op < Eop; op += 2) { if (op) Out << ", "; - Out << '['; + Out << '['; writeOperand(I.getOperand(op ), false); Out << ','; writeOperand(I.getOperand(op+1), false); Out << " ]"; } @@ -1096,7 +1096,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) { // and if the return type is not a pointer to a function. // if (!FTy->isVarArg() && - (!isa<PointerType>(RetTy) || + (!isa<PointerType>(RetTy) || !isa<FunctionType>(cast<PointerType>(RetTy)->getElementType()))) { Out << ' '; printType(RetTy); writeOperand(Operand, false); @@ -1121,7 +1121,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) { // and if the return type is not a pointer to a function. // if (!FTy->isVarArg() && - (!isa<PointerType>(RetTy) || + (!isa<PointerType>(RetTy) || !isa<FunctionType>(cast<PointerType>(RetTy)->getElementType()))) { Out << ' '; printType(RetTy); writeOperand(Operand, false); @@ -1162,7 +1162,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) { printType(VAN->getArgType()); } else if (Operand) { // Print the normal way... - // PrintAllTypes - Instructions who have operands of all the same type + // PrintAllTypes - Instructions who have operands of all the same type // omit the type from all but the first operand. If the instruction has // different type operands (for example br), then they are all printed. bool PrintAllTypes = false; @@ -1181,7 +1181,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) { } } } - + if (!PrintAllTypes) { Out << ' '; printType(TheType); @@ -1223,7 +1223,7 @@ void Function::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const { void BasicBlock::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const { SlotMachine SlotTable(getParent()); - AssemblyWriter W(o, SlotTable, + AssemblyWriter W(o, SlotTable, getParent() ? getParent()->getParent() : 0, AAW); W.write(this); } @@ -1245,7 +1245,7 @@ void Constant::print(std::ostream &o) const { WriteConstantInt(o, this, false, TypeTable, 0); } -void Type::print(std::ostream &o) const { +void Type::print(std::ostream &o) const { if (this == 0) o << "<null Type>"; else @@ -1294,7 +1294,7 @@ CachedWriter &CachedWriter::operator<<(const Value &V) { AW->write(F); else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(&V)) AW->write(GV); - else + else AW->writeOperand(&V, true, true); return *this; } @@ -1321,7 +1321,7 @@ CachedWriter& CachedWriter::operator<<(const Type &Ty) { // Module level constructor. Causes the contents of the Module (sans functions) // to be added to the slot table. -SlotMachine::SlotMachine(const Module *M) +SlotMachine::SlotMachine(const Module *M) : TheModule(M) ///< Saved for lazy initialization. , TheFunction(0) , FunctionProcessed(false) @@ -1334,7 +1334,7 @@ SlotMachine::SlotMachine(const Module *M) // Function level constructor. Causes the contents of the Module and the one // function provided to be added to the slot table. -SlotMachine::SlotMachine(const Function *F ) +SlotMachine::SlotMachine(const Function *F ) : TheModule( F ? F->getParent() : 0 ) ///< Saved for lazy initialization , TheFunction(F) ///< Saved for lazy initialization , FunctionProcessed(false) @@ -1346,17 +1346,17 @@ SlotMachine::SlotMachine(const Function *F ) } inline void SlotMachine::initialize(void) { - if ( TheModule) { - processModule(); + if ( TheModule) { + processModule(); TheModule = 0; ///< Prevent re-processing next time we're called. } - if ( TheFunction && ! FunctionProcessed) { - processFunction(); + if ( TheFunction && ! FunctionProcessed) { + processFunction(); } } // Iterate through all the global variables, functions, and global -// variable initializers and create slots for them. +// variable initializers and create slots for them. void SlotMachine::processModule() { SC_DEBUG("begin processModule!\n"); @@ -1379,14 +1379,14 @@ void SlotMachine::processFunction() { SC_DEBUG("begin processFunction!\n"); // Add all the function arguments - for(Function::const_arg_iterator AI = TheFunction->arg_begin(), + for(Function::const_arg_iterator AI = TheFunction->arg_begin(), AE = TheFunction->arg_end(); AI != AE; ++AI) createSlot(AI); SC_DEBUG("Inserting Instructions:\n"); // Add all of the basic blocks and instructions - for (Function::const_iterator BB = TheFunction->begin(), + for (Function::const_iterator BB = TheFunction->begin(), E = TheFunction->end(); BB != E; ++BB) { createSlot(BB); for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) { @@ -1417,8 +1417,8 @@ void SlotMachine::purgeFunction() { /// Types are forbidden because Type does not inherit from Value (any more). int SlotMachine::getSlot(const Value *V) { assert( V && "Can't get slot for null Value" ); - assert(!isa<Constant>(V) || isa<GlobalValue>(V) && - "Can't insert a non-GlobalValue Constant into SlotMachine"); + assert(!isa<Constant>(V) || isa<GlobalValue>(V) && + "Can't insert a non-GlobalValue Constant into SlotMachine"); // Check for uninitialized state and do lazy initialization this->initialize(); @@ -1445,7 +1445,7 @@ int SlotMachine::getSlot(const Value *V) { if (MVI == MI->second.map.end()) return -1; assert( MVI != MI->second.map.end() && "Value not found"); // We found it only at the module level - return MVI->second; + return MVI->second; // else the value exists in the function map } else { @@ -1489,10 +1489,10 @@ int SlotMachine::getSlot(const Type *Ty) { if ( FTI == fTypes.map.end() ) { TypeMap::const_iterator MTI = mTypes.map.find(Ty); // If we didn't find it, it wasn't inserted - if (MTI == mTypes.map.end()) + if (MTI == mTypes.map.end()) return -1; // We found it only at the module level - return MTI->second; + return MTI->second; // else the value exists in the function map } else { @@ -1518,8 +1518,8 @@ int SlotMachine::getSlot(const Type *Ty) { // of asserting when the Value* isn't found, it inserts the value. unsigned SlotMachine::createSlot(const Value *V) { assert( V && "Can't insert a null Value to SlotMachine"); - assert(!isa<Constant>(V) || isa<GlobalValue>(V) && - "Can't insert a non-GlobalValue Constant into SlotMachine"); + assert(!isa<Constant>(V) || isa<GlobalValue>(V) && + "Can't insert a non-GlobalValue Constant into SlotMachine"); const Type* VTy = V->getType(); @@ -1587,7 +1587,7 @@ unsigned SlotMachine::createSlot(const Value *V) { if ( MI != mMap.end() ) { // Lookup the value in the module's map ValueMap::const_iterator MVI = MI->second.map.find(V); - if ( MVI != MI->second.map.end() ) + if ( MVI != MI->second.map.end() ) return MVI->second; } @@ -1627,7 +1627,7 @@ unsigned SlotMachine::createSlot(const Type *Ty) { // Lookup the type in the module's map TypeMap::const_iterator MTI = mTypes.map.find(Ty); - if ( MTI != mTypes.map.end() ) + if ( MTI != mTypes.map.end() ) return MTI->second; return insertValue(Ty); @@ -1637,11 +1637,11 @@ unsigned SlotMachine::createSlot(const Type *Ty) { // function is just for the convenience of createSlot (above). unsigned SlotMachine::insertValue(const Value *V ) { assert(V && "Can't insert a null Value into SlotMachine!"); - assert(!isa<Constant>(V) || isa<GlobalValue>(V) && - "Can't insert a non-GlobalValue Constant into SlotMachine"); + assert(!isa<Constant>(V) || isa<GlobalValue>(V) && + "Can't insert a non-GlobalValue Constant into SlotMachine"); // If this value does not contribute to a plane (is void) - // or if the value already has a name then ignore it. + // or if the value already has a name then ignore it. if (V->getType() == Type::VoidTy || V->hasName() ) { SC_DEBUG("ignored value " << *V << "\n"); return 0; // FIXME: Wrong return value @@ -1652,7 +1652,7 @@ unsigned SlotMachine::insertValue(const Value *V ) { if ( TheFunction ) { TypedPlanes::iterator I = fMap.find( VTy ); - if ( I == fMap.end() ) + if ( I == fMap.end() ) I = fMap.insert(std::make_pair(VTy,ValuePlane())).first; DestSlot = I->second.map[V] = I->second.next_slot++; } else { @@ -1662,10 +1662,10 @@ unsigned SlotMachine::insertValue(const Value *V ) { DestSlot = I->second.map[V] = I->second.next_slot++; } - SC_DEBUG(" Inserting value [" << VTy << "] = " << V << " slot=" << + SC_DEBUG(" Inserting value [" << VTy << "] = " << V << " slot=" << DestSlot << " ["); // G = Global, C = Constant, T = Type, F = Function, o = other - SC_DEBUG((isa<GlobalVariable>(V) ? 'G' : (isa<Function>(V) ? 'F' : + SC_DEBUG((isa<GlobalVariable>(V) ? 'G' : (isa<Function>(V) ? 'F' : (isa<Constant>(V) ? 'C' : 'o')))); SC_DEBUG("]\n"); return DestSlot; diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp index 1d70b00d24..a9fb9247c1 100644 --- a/lib/VMCore/BasicBlock.cpp +++ b/lib/VMCore/BasicBlock.cpp @@ -1,10 +1,10 @@ //===-- BasicBlock.cpp - Implement BasicBlock related methods -------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the BasicBlock class for the VMCore library. @@ -130,7 +130,7 @@ BasicBlock *BasicBlock::getSinglePredecessor() { /// removePredecessor - This method is used to notify a BasicBlock that the /// specified Predecessor of the block is no longer able to reach it. This is -/// actually not used to update the Predecessor list, but is actually used to +/// actually not used to update the Predecessor list, but is actually used to /// update the PHI nodes that reside in the block. Note that this should be /// called while the predecessor still refers to this block. /// @@ -153,9 +153,9 @@ void BasicBlock::removePredecessor(BasicBlock *Pred, // br Loop ;; %x2 does not dominate all uses // // This is because the PHI node input is actually taken from the predecessor - // basic block. The only case this can happen is with a self loop, so we + // basic block. The only case this can happen is with a self loop, so we // check for this case explicitly now. - // + // unsigned max_idx = APN->getNumIncomingValues(); assert(max_idx != 0 && "PHI Node in block with 0 predecessors!?!?!"); if (max_idx == 2) { @@ -197,18 +197,18 @@ void BasicBlock::removePredecessor(BasicBlock *Pred, /// splitBasicBlock - This splits a basic block into two at the specified /// instruction. Note that all instructions BEFORE the specified iterator stay -/// as part of the original basic block, an unconditional branch is added to +/// as part of the original basic block, an unconditional branch is added to /// the new BB, and the rest of the instructions in the BB are moved to the new /// BB, including the old terminator. This invalidates the iterator. /// -/// Note that this only works on well formed basic blocks (must have a +/// Note that this only works on well formed basic blocks (must have a /// terminator), and 'I' must not be the end of instruction list (which would /// cause a degenerate basic block to be formed, having a terminator inside of -/// the basic block). +/// the basic block). /// BasicBlock *BasicBlock::splitBasicBlock(iterator I, const std::string &BBName) { assert(getTerminator() && "Can't use splitBasicBlock on degenerate BB!"); - assert(I != InstList.end() && + assert(I != InstList.end() && "Trying to get me to create degenerate basic block!"); BasicBlock *New = new BasicBlock(BBName, getParent(), getNext()); diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 772b79a29a..9ca8de302f 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -1,10 +1,10 @@ //===- ConstantFolding.cpp - LLVM constant folder -------------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements folding of constants for LLVM. This implements the @@ -30,7 +30,7 @@ using namespace llvm; namespace { struct ConstRules { ConstRules() {} - + // Binary Operators... virtual Constant *add(const Constant *V1, const Constant *V2) const = 0; virtual Constant *sub(const Constant *V1, const Constant *V2) const = 0; @@ -59,7 +59,7 @@ namespace { virtual Constant *castToDouble(const Constant *V) const = 0; virtual Constant *castToPointer(const Constant *V, const PointerType *Ty) const = 0; - + // ConstRules::get - Return an instance of ConstRules for the specified // constant operands. // @@ -75,11 +75,11 @@ namespace { // TemplateRules Class //===----------------------------------------------------------------------===// // -// TemplateRules - Implement a subclass of ConstRules that provides all -// operations as noops. All other rules classes inherit from this class so -// that if functionality is needed in the future, it can simply be added here +// TemplateRules - Implement a subclass of ConstRules that provides all +// operations as noops. All other rules classes inherit from this class so +// that if functionality is needed in the future, it can simply be added here // and to ConstRules without changing anything else... -// +// // This class also provides subclasses with typesafe implementations of methods // so that don't have to do type casting. // @@ -90,41 +90,41 @@ class TemplateRules : public ConstRules { // Redirecting functions that cast to the appropriate types //===--------------------------------------------------------------------===// - virtual Constant *add(const Constant *V1, const Constant *V2) const { - return SubClassName::Add((const ArgType *)V1, (const ArgType *)V2); + virtual Constant *add(const Constant *V1, const Constant *V2) const { + return SubClassName::Add((const ArgType *)V1, (const ArgType *)V2); } - virtual Constant *sub(const Constant *V1, const Constant *V2) const { - return SubClassName::Sub((const ArgType *)V1, (const ArgType *)V2); + virtual Constant *sub(const Constant *V1, const Constant *V2) const { + return SubClassName::Sub((const ArgType *)V1, (const ArgType *)V2); } - virtual Constant *mul(const Constant *V1, const Constant *V2) const { - return SubClassName::Mul((const ArgType *)V1, (const ArgType *)V2); + virtual Constant *mul(const Constant *V1, const Constant *V2) const { + return SubClassName::Mul((const ArgType *)V1, (const ArgType *)V2); } - virtual Constant *div(const Constant *V1, const Constant *V2) const { - return SubClassName::Div((const ArgType *)V1, (const ArgType *)V2); + virtual Constant *div(const Constant *V1, const Constant *V2) const { + return SubClassName::Div((const ArgType *)V1, (const ArgType *)V2); } - virtual Constant *rem(const Constant *V1, const Constant *V2) const { - return SubClassName::Rem((const ArgType *)V1, (const ArgType *)V2); + virtual Constant *rem(const Constant *V1, const Constant *V2) const { + return SubClassName::Rem((const ArgType *)V1, (const ArgType *)V2); } - virtual Constant *op_and(const Constant *V1, const Constant *V2) const { - return SubClassName::And((const ArgType *)V1, (const ArgType *)V2); + virtual Constant *op_and(const Constant *V1, const Constant *V2) const { + return SubClassName::And((const ArgType *)V1, (const ArgType *)V2); } - virtual Constant *op_or(const Constant *V1, const Constant *V2) const { - return SubClassName::Or((const ArgType *)V1, (const ArgType *)V2); + virtual Constant *op_or(const Constant *V1, const Constant *V2) const { + return SubClassName::Or((const ArgType *)V1, (const ArgType *)V2); } - virtual Constant *op_xor(const Constant *V1, const Constant *V2) const { - return SubClassName::Xor((const ArgType *)V1, (const ArgType *)V2); + virtual Constant *op_xor(const Constant *V1, const Constant *V2) const { + return SubClassName::Xor((const ArgType *)V1, (const ArgType *)V2); } - virtual Constant *shl(const Constant *V1, const Constant *V2) const { - return SubClassName::Shl((const ArgType *)V1, (const ArgType *)V2); + virtual Constant *shl(const Constant *V1, const Constant *V2) const { + return SubClassName::Shl((const ArgType *)V1, (const ArgType *)V2); } - virtual Constant *shr(const Constant *V1, const Constant *V2) const { - return SubClassName::Shr((const ArgType *)V1, (const ArgType *)V2); + virtual Constant *shr(const Constant *V1, const Constant *V2) const { + return SubClassName::Shr((const ArgType *)V1, (const ArgType *)V2); } - virtual Constant *lessthan(const Constant *V1, const Constant *V2) const { + virtual Constant *lessthan(const Constant *V1, const Constant *V2) const { return SubClassName::LessThan((const ArgType *)V1, (const ArgType *)V2); } - virtual Constant *equalto(const Constant *V1, const Constant *V2) const { + virtual Constant *equalto(const Constant *V1, const Constant *V2) const { return SubClassName::EqualTo((const ArgType *)V1, (const ArgType *)V2); } @@ -162,7 +162,7 @@ class TemplateRules : public ConstRules { virtual Constant *castToDouble(const Constant *V) const { return SubClassName::CastToDouble((const ArgType*)V); } - virtual Constant *castToPointer(const Constant *V, + virtual Constant *castToPointer(const Constant *V, const PointerType *Ty) const { return SubClassName::CastToPointer((const ArgType*)V, Ty); } @@ -357,7 +357,7 @@ struct DirectRules : public TemplateRules<ConstantClass, SuperClass> { static Constant *LessThan(const ConstantClass *V1, const ConstantClass *V2) { bool R = (BuiltinType)V1->getValue() < (BuiltinType)V2->getValue(); return ConstantBool::get(R); - } + } static Constant *EqualTo(const ConstantClass *V1, const ConstantClass *V2) { bool R = (BuiltinType)V1->getValue() == (BuiltinType)V2->getValue(); @@ -654,7 +654,7 @@ static int IdxCompare(Constant *C1, Constant *C2, const Type *ElTy) { // ConstantExprs? If so, we can't do anything with them. if (!isa<ConstantInt>(C1) || !isa<ConstantInt>(C2)) return -2; // don't know! - + // Ok, we have two differing integer indices. Sign extend them to be the same // type. Long is always big enough, so we use it. C1 = ConstantExpr::getSignExtend(C1, Type::LongTy); @@ -798,7 +798,7 @@ static Instruction::BinaryOps evaluateRelation(const Constant *V1, // same global. From this, we can precisely determine the relative // ordering of the resultant pointers. unsigned i = 1; - + // Compare all of the operands the GEP's have in common. gep_type_iterator GTI = gep_type_begin(CE1); for (;i != CE1->getNumOperands() && i != CE2->getNumOperands(); @@ -818,7 +818,7 @@ static Instruction::BinaryOps evaluateRelation(const Constant *V1, return Instruction::SetGT; else return Instruction::BinaryOpsEnd; // Might be equal. - + for (; i < CE2->getNumOperands(); ++i) if (!CE2->getOperand(i)->isNullValue()) if (isa<ConstantIntegral>(CE2->getOperand(i))) @@ -829,7 +829,7 @@ static Instruction::BinaryOps evaluateRelation(const Constant *V1, } } } - + default: break; } @@ -910,7 +910,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, if (Opcode == Instruction::SetLT) return ConstantBool::False; if (Opcode == Instruction::SetGT) return ConstantBool::True; break; - + case Instruction::SetNE: // If we know that V1 != V2, we can only partially decide this relation. if (Opcode == Instruction::SetEQ) return ConstantBool::False; @@ -1115,12 +1115,12 @@ Constant *llvm::ConstantFoldGetElementPtr(const Constant *C, if (!Idx0->isNullValue()) { const Type *IdxTy = Combined->getType(); if (IdxTy != Idx0->getType()) IdxTy = Type::LongTy; - Combined = + Combined = ConstantExpr::get(Instruction::Add, ConstantExpr::getCast(Idx0, IdxTy), ConstantExpr::getCast(Combined, IdxTy)); } - + NewIndices.push_back(Combined); NewIndices.insert(NewIndices.end(), IdxList.begin()+1, IdxList.end()); return ConstantExpr::getGetElementPtr(CE->getOperand(0), NewIndices); @@ -1134,7 +1134,7 @@ Constant *llvm::ConstantFoldGetElementPtr(const Constant *C, // if (CE->getOpcode() == Instruction::Cast && IdxList.size() > 1 && Idx0->isNullValue()) - if (const PointerType *SPT = + if (const PointerType *SPT = dyn_cast<PointerType>(CE->getOperand(0)->getType())) if (const ArrayType *SAT = dyn_cast<ArrayType>(SPT->getElementType())) if (const ArrayType *CAT = diff --git a/lib/VMCore/ConstantFold.h b/lib/VMCore/ConstantFold.h index 84e358c5df..a864aa2cd8 100644 --- a/lib/VMCore/ConstantFold.h +++ b/lib/VMCore/ConstantFold.h @@ -1,10 +1,10 @@ //===-- ConstantFolding.h - Internal Constant Folding Interface -*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file defines the (internal) constant folding interfaces for LLVM. These @@ -25,7 +25,7 @@ namespace llvm { class Value; class Constant; class Type; - + // Constant fold various types of instruction... Constant *ConstantFoldCastInstruction(const Constant *V, const Type *DestTy); Constant *ConstantFoldSelectInstruction(const Constant *Cond, diff --git a/lib/VMCore/ConstantFolding.h b/lib/VMCore/ConstantFolding.h index 84e358c5df..a864aa2cd8 100644 --- a/lib/VMCore/ConstantFolding.h +++ b/lib/VMCore/ConstantFolding.h @@ -1,10 +1,10 @@ //===-- ConstantFolding.h - Internal Constant Folding Interface -*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file defines the (internal) constant folding interfaces for LLVM. These @@ -25,7 +25,7 @@ namespace llvm { class Value; class Constant; class Type; - + // Constant fold various types of instruction... Constant *ConstantFoldCastInstruction(const Constant *V, const Type *DestTy); Constant *ConstantFoldSelectInstruction(const Constant *Cond, diff --git a/lib/VMCore/ConstantRange.cpp b/lib/VMCore/ConstantRange.cpp index 3b91c5bc7a..109ed42cfc 100644 --- a/lib/VMCore/ConstantRange.cpp +++ b/lib/VMCore/ConstantRange.cpp @@ -1,10 +1,10 @@ //===-- ConstantRange.cpp - ConstantRange implementation ------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // Represent a range of possible values that may occur when the program is run @@ -32,7 +32,7 @@ using namespace llvm; static ConstantIntegral *Next(ConstantIntegral *CI) { if (CI->getType() == Type::BoolTy) return CI == ConstantBool::True ? ConstantBool::False : ConstantBool::True; - + Constant *Result = ConstantExpr::getAdd(CI, ConstantInt::get(CI->getType(), 1)); return cast<ConstantIntegral>(Result); @@ -84,7 +84,7 @@ ConstantRange::ConstantRange(Constant *L, Constant *U) : Lower(cast<ConstantIntegral>(L)), Upper(cast<ConstantIntegral>(U)) { assert(Lower->getType() == Upper->getType() && "Incompatible types for ConstantRange!"); - + // Make sure that if L & U are equal that they are either Min or Max... assert((L != U || (L == ConstantIntegral::getMaxValue(L->getType()) || L == ConstantIntegral::getMinValue(L->getType()))) && @@ -126,7 +126,7 @@ const Type *ConstantRange::getType() const { return Lower->getType(); } bool ConstantRange::isFullSet() const { return Lower == Upper && Lower == ConstantIntegral::getMaxValue(getType()); } - + /// isEmptySet - Return true if this set contains no members. /// bool ConstantRange::isEmptySet() const { @@ -140,7 +140,7 @@ bool ConstantRange::isWrappedSet() const { return GT(Lower, Upper); } - + /// getSingleElement - If this set contains a single element, return it, /// otherwise return null. ConstantIntegral *ConstantRange::getSingleElement() const { @@ -158,7 +158,7 @@ uint64_t ConstantRange::getSetSize() const { return 1; return 2; // Must be full set... } - + // Simply subtract the bounds... Constant *Result = ConstantExpr::getSub(Upper, Lower); return cast<ConstantInt>(Result)->getRawValue(); diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index ee60f804b3..2bedef5585 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -1,10 +1,10 @@ //===-- Constants.cpp - Implement Constant nodes --------------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the Constant* classes... @@ -108,7 +108,7 @@ Constant *Constant::getNullValue(const Type *Ty) { return NullDouble; } - case Type::PointerTyID: + case Type::PointerTyID: return ConstantPointerNull::get(cast<PointerType>(Ty)); case Type::StructTyID: @@ -130,7 +130,7 @@ ConstantIntegral *ConstantIntegral::getMaxValue(const Type *Ty) { case Type::ShortTyID: case Type::IntTyID: case Type::LongTyID: { - // Calculate 011111111111111... + // Calculate 011111111111111... unsigned TypeBits = Ty->getPrimitiveSize()*8; int64_t Val = INT64_MAX; // All ones Val >>= 64-TypeBits; // Shift out unwanted 1 bits... @@ -154,7 +154,7 @@ ConstantIntegral *ConstantIntegral::getMinValue(const Type *Ty) { case Type::ShortTyID: case Type::IntTyID: case Type::LongTyID: { - // Calculate 1111111111000000000000 + // Calculate 1111111111000000000000 unsigned TypeBits = Ty->getPrimitiveSize()*8; int64_t Val = -1; // All ones Val <<= TypeBits-1; // Shift over to the right spot @@ -347,7 +347,7 @@ struct GetElementPtrConstantExpr : public ConstantExpr { OperandList[i+1].init(IdxList[i], this); } ~GetElementPtrConstantExpr() { - delete [] OperandList; + delete [] OperandList; } }; @@ -489,7 +489,7 @@ void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To, if (Val == From) Val = cast<Constant>(To); Values.push_back(Val); } - + Constant *Replacement = ConstantArray::get(getType(), Values); assert(Replacement != this && "I didn't contain From!"); @@ -498,9 +498,9 @@ void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To, uncheckedReplaceAllUsesWith(Replacement); else replaceAllUsesWith(Replacement); - + // Delete the old constant! - destroyConstant(); + destroyConstant(); } void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To, @@ -514,7 +514,7 @@ void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To, if (Val == From) Val = cast<Constant>(To); Values.push_back(Val); } - + Constant *Replacement = ConstantStruct::get(getType(), Values); assert(Replacement != this && "I didn't contain From!"); @@ -523,7 +523,7 @@ void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To, uncheckedReplaceAllUsesWith(Replacement); else replaceAllUsesWith(Replacement); - + // Delete the old constant! destroyConstant(); } @@ -539,7 +539,7 @@ void ConstantPacked::replaceUsesOfWithOnConstant(Value *From, Value *To, if (Val == From) Val = cast<Constant>(To); Values.push_back(Val); } - + Constant *Replacement = ConstantPacked::get(getType(), Values); assert(Replacement != this && "I didn't contain From!"); @@ -548,9 +548,9 @@ void ConstantPacked::replaceUsesOfWithOnConstant(Value *From, Value *To, uncheckedReplaceAllUsesWith(Replacement); else replaceAllUsesWith(Replacement); - + // Delete the old constant! - destroyConstant(); + destroyConstant(); } void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV, @@ -564,7 +564,7 @@ void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV, Constant *Pointer = getOperand(0); Indices.reserve(getNumOperands()-1); if (Pointer == From) Pointer = To; - + for (unsigned i = 1, e = getNumOperands(); i != e; ++i) { Constant *Val = getOperand(i); if (Val == From) Val = To; @@ -592,7 +592,7 @@ void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV, assert(0 && "Unknown ConstantExpr type!"); return; } - + assert(Replacement != this && "I didn't contain From!"); // Everyone using this now uses the replacement... @@ -600,7 +600,7 @@ void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV, uncheckedReplaceAllUsesWith(Replacement); else replaceAllUsesWith(Replacement); - + // Delete the old constant! destroyConstant(); } @@ -620,7 +620,7 @@ namespace llvm { return new ConstantClass(Ty, V); } }; - + template<class ConstantClass, class TypeClass> struct ConvertConstantType { static void convert(ConstantClass *OldC, const TypeClass *NewTy) { @@ -683,7 +683,7 @@ namespace { } return Result; } - + void remove(ConstantClass *CP) { MapIterator I = Map.find(MapKey((TypeClass*)CP->getRawType(), getValType(CP))); @@ -708,14 +708,14 @@ namespace { // Yes, we are removing the representative entry for this type. // See if there are any other entries of the same type. MapIterator TmpIt = ATMEntryIt; - + // First check the entry before this one... if (TmpIt != Map.begin()) { --TmpIt; if (TmpIt->first.first != Ty) // Not the same type, move back... ++TmpIt; } - + // If we didn't find the same type, try to move forward... if (TmpIt == ATMEntryIt) { ++TmpIt; @@ -735,12 +735,12 @@ namespace { } } } - + Map.erase(I); } void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) { - typename AbstractTypeMapTy::iterator I = + typename AbstractTypeMapTy::iterator I = AbstractTypeMap.find(cast<TypeClass>(OldTy)); assert(I != AbstractTypeMap.end() && @@ -995,14 +995,14 @@ namespace llvm { C.push_back(cast<Constant>(OldC->getOperand(i))); Constant *New = ConstantStruct::get(NewTy, C); assert(New != OldC && "Didn't replace constant??"); - + OldC->uncheckedReplaceAllUsesWith(New); OldC->destroyConstant(); // This constant is now dead, destroy it. } }; } -static ValueMap<std::vector<Constant*>, StructType, +static ValueMap<std::vector<Constant*>, StructType, ConstantStruct> StructConstants; static std::vector<Constant*> getValType(ConstantStruct *CS) { @@ -1197,9 +1197,9 @@ namespace llvm { return new BinaryConstantExpr(V.first, V.second[0], V.second[1]); if (V.first == Instruction::Select) return new SelectConstantExpr(V.second[0], V.second[1], V.second[2]); - + assert(V.first == Instruction::GetElementPtr && "Invalid ConstantExpr!"); - + std::vector<Constant*> IdxList(V.second.begin()+1, V.second.end()); return new GetElementPtrConstantExpr(V.second[0], IdxList, Ty); } @@ -1230,12 +1230,12 @@ namespace llvm { OldC->getOperand(1)); break; case Instruction::GetElementPtr: - // Make everyone now use a constant of the new type... + // Make everyone now use a constant of the new type... std::vector<Value*> Idx(OldC->op_begin()+1, OldC->op_end()); New = ConstantExpr::getGetElementPtrTy(NewTy, OldC->getOperand(0), Idx); break; } - + assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); OldC->destroyConstant(); // This constant is now dead, destroy it. @@ -1333,7 +1333,7 @@ Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) { case Instruction::Mul: case Instruction::Div: case Instruction::Rem: assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert((C1->getType()->isInteger() || C1->getType()->isFloatingPoint()) && + assert((C1->getType()->isInteger() || C1->getType()->isFloatingPoint()) && "Tried to create an arithmetic operation on a non-arithmetic type!"); break; case Instruction::And: @@ -1471,7 +1471,7 @@ void Constant::clearAllValueMaps() { UndefValueConstants.clear(Constants); ExprConstants.clear(Constants); - for (std::vector<Constant *>::iterator I = Constants.begin(), + for (std::vector<Constant *>::iterator I = Constants.begin(), E = Constants.end(); I != E; ++I) (*I)->dropAllReferences(); for (std::vector<Constant *>::iterator I = Constants.begin(), diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index b70c7b5155..220c7d9997 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -1,10 +1,10 @@ //===- Dominators.cpp - Dominator Calculation -----------------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements simple dominator construction algorithms for finding @@ -74,7 +74,7 @@ void ImmediateDominators::Compress(BasicBlock *V, InfoRec &VInfo) { Compress(VAncestor, VAInfo); - BasicBlock *VAncestorLabel = VAInfo.Label; + BasicBlock *VAncestorLabel = VAInfo.Label; BasicBlock *VLabel = VInfo.Label; if (Info[VAncestorLabel].Semi < Info[VLabel].Semi) VInfo.Label = VAncestorLabel; @@ -115,10 +115,10 @@ void ImmediateDominators::Link(BasicBlock *V, BasicBlock *W, InfoRec &WInfo){ unsigned WLabelSemi = Info[WLabel].Semi; BasicBlock *S = W; InfoRec *SInfo = &Info[S]; - + BasicBlock *SChild = SInfo->Child; InfoRec *SChildInfo = &Info[SChild]; - + while (WLabelSemi < Info[SChildInfo->Label].Semi) { BasicBlock *SChildChild = SChildInfo->Child; if (SInfo->Size+Info[SChildChild].Size >= 2*SChildInfo->Size) { @@ -133,17 +133,17 @@ void ImmediateDominators::Link(BasicBlock *V, BasicBlock *W, InfoRec &WInfo){ SChildInfo = &Info[SChild]; } } - + InfoRec &VInfo = Info[V]; SInfo->Label = WLabel; - + assert(V != W && "The optimization here will not work in this case!"); unsigned WSize = WInfo.Size; unsigned VSize = (VInfo.Size += WSize); - + if (VSize < 2*WSize) std::swap(S, VInfo.Child); - + while (S) { SInfo = &Info[S]; SInfo->Ancestor = V; @@ -161,7 +161,7 @@ bool ImmediateDominators::runOnFunction(Function &F) { Roots.push_back(Root); Vertex.push_back(0); - + // Step #1: Number blocks in depth-first order and initialize variables used // in later stages of the algorithm. unsigned N = 0; @@ -179,7 +179,7 @@ bool ImmediateDominators::runOnFunction(Function &F) { if (SemiU < WInfo.Semi) WInfo.Semi = SemiU; } - + Info[Vertex[WInfo.Semi]].Bucket.push_back(W); BasicBlock *WParent = WInfo.Parent; @@ -240,11 +240,11 @@ B("domset", "Dominator Set Construction", true); bool DominatorSetBase::dominates(Instruction *A, Instruction *B) const { BasicBlock *BBA = A->getParent(), *BBB = B->getParent(); if (BBA != BBB) return dominates(BBA, BBB); - + // Loop through the basic block until we find A or B. BasicBlock::iterator I = BBA->begin(); for (; &*I != A && &*I != B; ++I) /*empty*/; - + // A dominates B if it is found first in the basic block... return &*I == A; } @@ -275,8 +275,8 @@ bool DominatorSet::runOnFunction(Function &F) { DomSetType &DS = Doms[I]; assert(DS.empty() && "Domset already filled in for this block?"); DS.insert(I); // Blocks always dominate themselves - - // Insert all dominators into the set... + + // Insert all dominators into the set... while (IDom) { // If we have already computed the dominator sets for our immediate // dominator, just use it instead of walking all the way up to the root. @@ -333,7 +333,7 @@ E("domtree", "Dominator Tree Construction", true); // DominatorTreeBase::reset - Free all of the tree node memory. // -void DominatorTreeBase::reset() { +void DominatorTreeBase::reset() { for (NodeMapType::iterator I = Nodes.begin(), E = Nodes.end(); I != E; ++I) delete I->second; Nodes.clear(); @@ -364,7 +364,7 @@ DominatorTreeBase::Node *DominatorTree::getNodeForBlock(BasicBlock *BB) { // immediate dominator. BasicBlock *IDom = getAnalysis<ImmediateDominators>()[BB]; Node *IDomNode = getNodeForBlock(IDom); - + // Add a new tree node for this BasicBlock, and link it as a child of // IDomNode return BBNode = IDomNode->addChild(new Node(BB, IDomNode)); @@ -403,7 +403,7 @@ static std::ostream &operator<<(std::ostream &o, static void PrintDomTree(const DominatorTreeBase::Node *N, std::ostream &o, unsigned Lev) { o << std::string(2*Lev, ' ') << "[" << Lev << "] " << N; - for (DominatorTreeBase::Node::const_iterator I = N->begin(), E = N->end(); + for (DominatorTreeBase::Node::const_iterator I = N->begin(), E = N->end(); I != E; ++I) PrintDomTree(*I, o, Lev+1); } @@ -423,7 +423,7 @@ static RegisterAnalysis<DominanceFrontier> G("domfrontier", "Dominance Frontier Construction", true); const DominanceFrontier::DomSetType & -DominanceFrontier::calculate(const DominatorTree &DT, +DominanceFrontier::calculate(const DominatorTree &DT, const DominatorTree::Node *Node) { // Loop over CFG successors to calculate DFlocal[Node] BasicBlock *BB = Node->getBlock(); diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index b883e07ddf..2672e892c7 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -1,10 +1,10 @@ //===-- Function.cpp - Implement the Global object classes ----------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the Function & GlobalVariable classes for the VMCore @@ -51,7 +51,7 @@ template class SymbolTableListTraits<BasicBlock, Function, Function>; // Argument Implementation //===----------------------------------------------------------------------===// -Argument::Argument(const Type *Ty, const std::string &Name, Function *Par) +Argument::Argument(const Type *Ty, const std::string &Name, Function *Par) : Value(Ty, Value::ArgumentVal, Name) { Parent = 0; @@ -125,7 +125,7 @@ bool Function::isVarArg() const { return getFunctionType()->isVarArg(); } -const Type *Function::getReturnType() const { +const Type *Function::getReturnType() const { return getFunctionType()->getReturnType(); } @@ -182,7 +182,7 @@ void Function::renameLocalSymbols() { // 'delete' a whole class at a time, even though there may be circular // references... first all references are dropped, and all use counts go to // zero. Then everything is deleted for real. Note that no operations are -// valid on an object that has "dropped all references", except operator +// valid on an object that has "dropped all references", except operator // delete. // void Function::dropAllReferences() { @@ -204,7 +204,7 @@ unsigned Function::getIntrinsicID() const { return 0; // All intrinsics start with 'llvm.' assert(getName().size() != 5 && "'llvm.' is an invalid intrinsic name!"); - + switch (getName()[5]) { case 'd': if (getName() == "llvm.dbg.stoppoint") return Intrinsic::dbg_stoppoint; @@ -233,8 +233,8 @@ unsigned Function::getIntrinsicID() const { if (getName() == "llvm.memset") return Intrinsic::memset; break; case 'p': - if (getName() == "llvm.prefetch") return Intrinsic::prefetch; - if (getName() == "llvm.pcmarker") return Intrinsic::pcmarker; + if (getName() == "llvm.prefetch") return Intrinsic::prefetch; + if (getName() == "llvm.pcmarker") return Intrinsic::pcmarker; break; case 'r': if (getName() == "llvm.returnaddress") return Intrinsic::returnaddress; diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp index c0264ae3c1..87eca2a995 100644 --- a/lib/VMCore/Globals.cpp +++ b/lib/VMCore/Globals.cpp @@ -1,10 +1,10 @@ //===-- Globals.cpp - Implement the Global object classes -----------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the GlobalValue & GlobalVariable classes for the VMCore @@ -23,7 +23,7 @@ using namespace llvm; // GlobalValue Class //===----------------------------------------------------------------------===// -/// This could be named "SafeToDestroyGlobalValue". It just makes sure that +/// This could be named "SafeToDestroyGlobalValue". It just makes sure that /// there are no non-constant uses of this GlobalValue. If there aren't then /// this and the transitive closure of the constants can be deleted. See the /// destructor for details. @@ -32,7 +32,7 @@ static bool removeDeadConstantUsers(Constant* C) { while (!C->use_empty()) if (Constant *User = dyn_cast<Constant>(C->use_back())) { - if (!removeDeadConstantUsers(User)) + if (!removeDeadConstantUsers(User)) return false; // Constant wasn't dead } else { return false; // Non-constant usage; @@ -47,7 +47,7 @@ static bool removeDeadConstantUsers(Constant* C) { /// that want to check to see if a global is unused, but don't want to deal /// with potentially dead constants hanging off of the globals. /// -/// This function returns true if the global value is now dead. If all +/// This function returns true if the global value is now dead. If all /// users of this global are not dead, this method may return false and /// leave some of them around. void GlobalValue::removeDeadConstantUsers() { @@ -61,7 +61,7 @@ void GlobalValue::removeDeadConstantUsers() { } } -/// Override destroyConstant to make sure it doesn't get called on +/// Override destroyConstant to make sure it doesn't get called on /// GlobalValue's because they shouldn't be treated like other constants. void GlobalValue::destroyConstant() { assert(0 && "You can't GV->destroyConstant()!"); @@ -111,7 +111,7 @@ void GlobalVariable::replaceUsesOfWithOnConstant(Value *From, Value *To, bool DisableChecking) { // If you call this, then you better know this GVar has a constant // initializer worth replacing. Enforce that here. - assert(getNumOperands() == 1 && + assert(getNumOperands() == 1 && "Attempt to replace uses of Constants on a GVar with no initializer"); // And, since you know it has an initializer, the From value better be @@ -122,7 +122,7 @@ void GlobalVariable::replaceUsesOfWithOnConstant(Value *From, Value *To, // And, you better have a constant for the replacement value assert(isa<Constant>(To) && "Attempt to replace GVar initializer with non-constant"); - + // Okay, preconditions out of the way, replace the constant initializer. this->setOperand(0, cast<Constant>(To)); } diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index 4ccbd74dfd..2a4812831a 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -1,10 +1,10 @@ //===-- Instruction.cpp - Implement the Instruction class -----------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the Instruction class for the VMCore library. @@ -74,7 +74,7 @@ const char *Instruction::getOpcodeName(unsigned OpCode) { case Invoke: return "invoke"; case Unwind: return "unwind"; case Unreachable: return "unreachable"; - + // Standard binary operators... case Add: return "add"; case Sub: return "sub"; @@ -94,7 +94,7 @@ const char *Instruction::getOpcodeName(unsigned OpCode) { case SetGT: return "setgt"; case SetEQ: return "seteq"; case SetNE: return "setne"; - + // Memory instructions... case Malloc: return "malloc"; case Free: return "free"; @@ -102,7 +102,7 @@ const char *Instruction::getOpcodeName(unsigned OpCode) { case Load: return "load"; case Store: return "store"; case GetElementPtr: return "getelementptr"; - + // Other instructions... case PHI: return "phi"; case Cast: return "cast"; @@ -115,7 +115,7 @@ const char *Instruction::getOpcodeName(unsigned OpCode) { default: return "<Invalid operator> "; } - + return 0; } @@ -172,7 +172,7 @@ bool Instruction::isCommutative(unsigned op) { switch (op) { case Add: case Mul: - case And: + case And: case Or: case Xor: case SetEQ: diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index d3f766521d..c3eacddcc3 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -1,10 +1,10 @@ //===-- Instructions.cpp - Implement the LLVM instructions ----------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements all of the non-inline methods for the LLVM instruction @@ -25,7 +25,7 @@ using namespace llvm; //===----------------------------------------------------------------------===// TerminatorInst::TerminatorInst(Instruction::TermOps iType, - Use *Ops, unsigned NumOps, Instruction *IB) + Use *Ops, unsigned NumOps, Instruction *IB) : Instruction(Type::VoidTy, iType, Ops, NumOps, "", IB) { } @@ -104,7 +104,7 @@ void PHINode::resizeOperands(unsigned NumOps) { } else if (NumOps == NumOperands) { if (ReservedSpace == NumOps) return; } else { - return; + return; } ReservedSpace = NumOps; @@ -132,10 +132,10 @@ void CallInst::init(Value *Func, const std::vector<Value*> &Params) { Use *OL = OperandList = new Use[Params.size()+1]; OL[0].init(Func, this); - const FunctionType *FTy = + const FunctionType *FTy = cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType()); - assert((Params.size() == FTy->getNumParams() || + assert((Params.size() == FTy->getNumParams() || (FTy->isVarArg() && Params.size() > FTy->getNumParams())) && "Calling a function with bad signature"); for (unsigned i = 0, e = Params.size(); i != e; ++i) @@ -148,8 +148,8 @@ void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) { OL[0].init(Func, this); OL[1].init(Actual1, this); OL[2].init(Actual2, this); - - const FunctionType *FTy = + + const FunctionType *FTy = cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType()); assert((FTy->getNumParams() == 2 || @@ -162,8 +162,8 @@ void CallInst::init(Value *Func, Value *Actual) { Use *OL = OperandList = new Use[2]; OL[0].init(Func, this); OL[1].init(Actual, this); - - const FunctionType *FTy = + + const FunctionType *FTy = cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType()); assert((FTy->getNumParams() == 1 || @@ -175,23 +175,23 @@ void CallInst::init(Value *Func) { NumOperands = 1; Use *OL = OperandList = new Use[1]; OL[0].init(Func, this); - - const FunctionType *MTy = + + const FunctionType *MTy = cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType()); assert(MTy->getNumParams() == 0 && "Calling a function with bad signature"); } -CallInst::CallInst(Value *Func, const std::vector<Value*> &Params, - const std::string &Name, Instruction *InsertBefore) +CallInst::CallInst(Value *Func, const std::vector<Value*> &Params, + const std::string &Name, Instruction *InsertBefore) : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType()) ->getElementType())->getReturnType(), Instruction::Call, 0, 0, Name, InsertBefore) { init(Func, Params); } -CallInst::CallInst(Value *Func, const std::vector<Value*> &Params, - const std::string &Name, BasicBlock *InsertAtEnd) +CallInst::CallInst(Value *Func, const std::vector<Value*> &Params, + const std::string &Name, BasicBlock *InsertAtEnd) : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType()) ->getElementType())->getReturnType(), Instruction::Call, 0, 0, Name, InsertAtEnd) { @@ -246,7 +246,7 @@ CallInst::CallInst(Value *Func, const std::string &Name, init(Func); } -CallInst::CallInst(const CallInst &CI) +CallInst::CallInst(const CallInst &CI) : Instruction(CI.getType(), Instruction::Call, new Use[CI.getNumOperands()], CI.getNumOperands()) { Use *OL = OperandList; @@ -271,13 +271,13 @@ void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException, OL[0].init(Fn, this); OL[1].init(IfNormal, this); OL[2].init(IfException, this); - const FunctionType *FTy = + const FunctionType *FTy = cast<FunctionType>(cast<PointerType>(Fn->getType())->getElementType()); - - assert((Params.size() == FTy->getNumParams()) || + + assert((Params.size() == FTy->getNumParams()) || (FTy->isVarArg() && Params.size() > FTy->getNumParams()) && "Calling a function with bad signature"); - + for (unsigned i = 0, e = Params.size(); i != e; i++) OL[i+3].init(Params[i], this); } @@ -302,7 +302,7 @@ InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal, init(Fn, IfNormal, IfException, Params); } -InvokeInst::InvokeInst(const InvokeInst &II) +InvokeInst::InvokeInst(const InvokeInst &II) : TerminatorInst(II.getType(), Instruction::Invoke, new Use[II.getNumOperands()], II.getNumOperands()) { Use *OL = OperandList, *InOL = II.OperandList; @@ -327,7 +327,7 @@ void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) { void ReturnInst::init(Value *retVal) { if (retVal && retVal->getType() != Type::VoidTy) { - assert(!isa<BasicBlock>(retVal) && + assert(!isa<BasicBlock>(retVal) && "Cannot return basic block. Probably using the incorrect ctor"); NumOperands = 1; RetVal.init(retVal, this); @@ -393,7 +393,7 @@ BasicBlock *UnreachableInst::getSuccessorV(unsigned idx) const { void BranchInst::AssertOK() { if (isConditional()) - assert(getCondition()->getType() == Type::BoolTy && + assert(getCondition()->getType() == Type::BoolTy && "May only branch on boolean predicates!"); } @@ -428,10 +428,10 @@ static Value *getAISize(Value *Amt) { else assert(Amt->getType() == Type::UIntTy && "Malloc/Allocation array size != UIntTy!"); - return Amt; + return Amt; } -AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, +AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, const std::string &Name, Instruction *InsertBefore) : UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize), @@ -439,7 +439,7 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, assert(Ty != Type::VoidTy && "Cannot allocate void!"); } -AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, +AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, const std::string &Name, BasicBlock *InsertAtEnd) : UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize), @@ -492,7 +492,7 @@ FreeInst::FreeInst(Value *Ptr, BasicBlock *InsertAtEnd) //===----------------------------------------------------------------------===// void LoadInst::AssertOK() { - assert(isa<PointerType>(getOperand(0)->getType()) && + assert(isa<PointerType>(getOperand(0)->getType()) && "Ptr must have pointer type."); } @@ -556,7 +556,7 @@ StoreInst::StoreInst(Value *val, Value *addr, BasicBlock *InsertAtEnd) AssertOK(); } -StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, +StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, Instruction *InsertBefore) : Instruction(Type::VoidTy, Store, Ops, 2, "", InsertBefore) { Ops[0].init(val, this); @@ -565,7 +565,7 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, AssertOK(); } -StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, +StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, BasicBlock *InsertAtEnd) : Instruction(Type::VoidTy, Store, Ops, 2, "", InsertAtEnd) { Ops[0].init(val, this); @@ -642,10 +642,10 @@ GetElementPtrInst::~GetElementPtrInst() { // getIndexedType - Returns the type of the element that would be loaded with // a load instruction with the specified parameters. // -// A null type is returned if the indices are invalid for the specified +// A null type is returned if the indices are invalid for the specified // pointer type. // -const Type* GetElementPtrInst::getIndexedType(const Type *Ptr, +const Type* GetElementPtrInst::getIndexedType(const Type *Ptr, const std::vector<Value*> &Idx, bool AllowCompositeLeaf) { if (!isa<PointerType>(Ptr)) return 0; // Type isn't a pointer type! @@ -657,7 +657,7 @@ const Type* GetElementPtrInst::getIndexedType(const Type *Ptr, return cast<PointerType>(Ptr)->getElementType(); else return 0; - + unsigned CurIdx = 0; while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) { if (Idx.size() == CurIdx) { @@ -682,7 +682,7 @@ const Type* GetElementPtrInst::getIndexedType(const Type *Ptr, return CurIdx == Idx.size() ? Ptr : 0; } -const Type* GetElementPtrInst::getIndexedType(const Type *Ptr, +const Type* GetElementPtrInst::getIndexedType(const Type *Ptr, Value *Idx0, Value *Idx1, bool AllowCompositeLeaf) { const PointerType *PTy = dyn_cast<PointerType>(Ptr); @@ -716,9 +716,9 @@ void BinaryOperator::init(BinaryOps iType) case Rem: assert(getType() == LHS->getType() && "Arithmetic operation should return same type as operands!"); - assert((getType()->isInteger() || - getType()->isFloatingPoint() || - isa<PackedType>(getType()) ) && + assert((getType()->isInteger() || + getType()->isFloatingPoint() || + isa<PackedType>(getType()) ) && "Tried to create an arithmetic operation on a non-arithmetic type!"); break; case And: case Or: @@ -870,7 +870,7 @@ bool BinaryOperator::swapOperands() { // SetCondInst Class //===----------------------------------------------------------------------===// -SetCondInst::SetCondInst(BinaryOps Opcode, Value *S1, Value *S2, +SetCondInst::SetCondInst(BinaryOps Opcode, Value *S1, Value *S2, const std::string &Name, Instruction *InsertBefore) : BinaryOperator(Opcode, S1, S2, Type::BoolTy, Name, InsertBefore) { @@ -878,7 +878,7 @@ SetCondInst::SetCondInst(BinaryOps Opcode, Value *S1, Value *S2, assert(getInverseCondition(Opcode)); } -SetCondInst::SetCondInst(BinaryOps Opcode, Value *S1, Value *S2, +SetCondInst::SetCondInst(BinaryOps Opcode, Value *S1, Value *S2, const std::string &Name, BasicBlock *InsertAtEnd) : BinaryOperator(Opcode, S1, S2, Type::BoolTy, Name, InsertAtEnd) { @@ -931,7 +931,7 @@ void SwitchInst::init(Value *Value, BasicBlock *Default, unsigned NumCases) { OperandList[1].init(Default, this); } -SwitchInst::SwitchInst(const SwitchInst &SI) +SwitchInst::SwitchInst(const SwitchInst &SI) : TerminatorInst(Instruction::Switch, new Use[SI.getNumOperands()], SI.getNumOperands()) { Use *OL = OperandList, *InOL = SI.OperandList; diff --git a/lib/VMCore/LeakDetector.cpp b/lib/VMCore/LeakDetector.cpp index c8e7f4c6a5..7cf8e0d99a 100644 --- a/lib/VMCore/LeakDetector.cpp +++ b/lib/VMCore/LeakDetector.cpp @@ -1,10 +1,10 @@ //===-- LeakDetector.cpp - Implement LeakDetector interface ---------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the LeakDetector class. diff --git a/lib/VMCore/Mangler.cpp b/lib/VMCore/Mangler.cpp index 14830cb8f8..0847604b8f 100644 --- a/lib/VMCore/Mangler.cpp +++ b/lib/VMCore/Mangler.cpp @@ -1,10 +1,10 @@ //===-- Mangler.cpp - Self-contained c/asm llvm name mangler --------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // Unified name mangler for CWriter and assembly backends. @@ -27,10 +27,10 @@ static std::string MangleLetter(unsigned char C) { /// makeNameProper - We don't want identifier names non-C-identifier characters /// in them, so mangle them as appropriate. -/// +/// std::string Mangler::makeNameProper(const std::string &X) { std::string Result; - + // Mangle the first letter specially, don't allow numbers... if ((X[0] < 'a' || X[0] > 'z') && (X[0] < 'A' || X[0] > 'Z') && X[0] != '_') Result += MangleLetter(X[0]); @@ -85,7 +85,7 @@ std::string Mangler::getValueName(const Value *V) { } else { name = "ltmp_" + utostr(Count++) + "_" + utostr(getTypeID(V->getType())); } - + Memo[V] = name; return name; } diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index f9b8ca1277..a554d8e092 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -1,10 +1,10 @@ //===-- Module.cpp - Implement the Module class ---------------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the Module class for the VMCore library. @@ -174,7 +174,7 @@ Function *Module::getMainFunction() { if (Function *F = getFunction("main", FunctionType::get(Type::IntTy, Params, false))) return F; - + // void main(int argc, char **argv)... if (Function *F = getFunction("main", FunctionType::get(Type::VoidTy, Params, false))) @@ -212,7 +212,7 @@ Function *Module::getNamedFunction(const std::string &Name) { /// have the top-level PointerType, which represents the address of the /// global. /// -GlobalVariable *Module::getGlobalVariable(const std::string &Name, +GlobalVariable *Module::getGlobalVariable(const std::string &Name, const Type *Ty) { if (Value *V = getSymbolTable().lookup(PointerType::get(Ty), Name)) { GlobalVariable *Result = cast<GlobalVariable>(V); @@ -237,7 +237,7 @@ bool Module::addTypeName(const std::string &Name, const Type *Ty) { SymbolTable &ST = getSymbolTable(); if (ST.lookupType(Name)) return true; // Already in symtab... - + // Not in symbol table? Set the name with the Symtab as an argument so the // type knows what to update... ST.insert(Name, Ty); diff --git a/lib/VMCore/ModuleProvider.cpp b/lib/VMCore/ModuleProvider.cpp index 2b06c1145a..c9e4d87afe 100644 --- a/lib/VMCore/ModuleProvider.cpp +++ b/lib/VMCore/ModuleProvider.cpp @@ -1,10 +1,10 @@ //===-- ModuleProvider.cpp - Base implementation for module providers -----===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // Minimal implementation of the abstract interface for providing a module. diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index acde824a79..4ed7847567 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -1,10 +1,10 @@ //===- Pass.cpp - LLVM Pass Infrastructure Implementation -----------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the LLVM Pass infrastructure. It is primarily @@ -90,12 +90,12 @@ bool PassManager::run(Module &M) { return PM->runOnModule(M); } // is a simple Pimpl class that wraps the PassManagerT template. It // is like PassManager, but only deals in FunctionPasses. // -FunctionPassManager::FunctionPassManager(ModuleProvider *P) : +FunctionPassManager::FunctionPassManager(ModuleProvider *P) : PM(new PassManagerT<Function>()), MP(P) {} FunctionPassManager::~FunctionPassManager() { delete PM; } void FunctionPassManager::add(FunctionPass *P) { PM->add(P); } void FunctionPassManager::add(ImmutablePass *IP) { PM->add(IP); } -bool FunctionPassManager::run(Function &F) { +bool FunctionPassManager::run(Function &F) { try { MP->materializeFunction(&F); } catch (std::string& errstr) { @@ -149,7 +149,7 @@ void PMDebug::PrintArgumentInformation(const Pass *P) { void PMDebug::PrintPassInformation(unsigned Depth, const char *Action, Pass *P, Module *M) { if (PassDebugging >= Executions) { - std::cerr << (void*)P << std::string(Depth*2+1, ' ') << Action << " '" + std::cerr << (void*)P << std::string(Depth*2+1, ' ') << Action << " '" << P->getPassName(); if (M) std::cerr << "' on Module '" << M->getModuleIdentifier() << "'\n"; std::cerr << "'...\n"; @@ -159,7 +159,7 @@ void PMDebug::PrintPassInformation(unsigned Depth, const char *Action, void PMDebug::PrintPassInformation(unsigned Depth, const char *Action, Pass *P, Function *F) { if (PassDebugging >= Executions) { - std::cerr << (void*)P << std::string(Depth*2+1, ' ') << Action << " '" + std::cerr << (void*)P << std::string(Depth*2+1, ' ') << Action << " '" << P->getPassName(); if (F) std::cerr << "' on Function '" << F->getName(); std::cerr << "'...\n"; @@ -169,7 +169,7 @@ void PMDebug::PrintPassInformation(unsigned Depth, const char *Action, void PMDebug::PrintPassInformation(unsigned Depth, const char *Action, Pass *P, BasicBlock *BB) { if (PassDebugging >= Executions) { - std::cerr << (void*)P << std::string(Depth*2+1, ' ') << Action << " '" + std::cerr << (void*)P << std::string(Depth*2+1, ' ') << Action << " '" << P->getPassName(); if (BB) std::cerr << "' on BasicBlock '" << BB->getName(); std::cerr << "'...\n"; @@ -244,11 +244,11 @@ void ImmutablePass::addToPassManager(PassManagerT<Module> *PM, // bool FunctionPass::runOnModule(Module &M) { bool Changed = doInitialization(M); - + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isExternal()) // Passes are not run on external functions! Changed |= runOnFunction(*I); - + return Changed | doFinalization(M); } @@ -441,7 +441,7 @@ RegisterAGBase::~RegisterAGBase() { if (AGI.DefaultImpl == ImplementationInfo) AGI.DefaultImpl = 0; - + AGI.Implementations.erase(ImplementationInfo); // Last member of this analysis group? Unregister PassInfo, delete map entry diff --git a/lib/VMCore/PassManagerT.h b/lib/VMCore/PassManagerT.h index 8b3425adc3..b679f6ffd5 100644 --- a/lib/VMCore/PassManagerT.h +++ b/lib/VMCore/PassManagerT.h @@ -1,10 +1,10 @@ //===- PassManagerT.h - Container for Passes --------------------*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file defines the PassManagerT class. This class is used to hold, @@ -131,7 +131,7 @@ template<class UnitType> class PassManagerTraits; // Do not define. //===----------------------------------------------------------------------===// // PassManagerT - Container object for passes. The PassManagerT destructor -// deletes all passes contained inside of the PassManagerT, so you shouldn't +// deletes all passes contained inside of the PassManagerT, so you shouldn't // delete passes manually, and all passes should be dynamically allocated. // template<typename UnitType> @@ -147,7 +147,7 @@ class PassManagerT : public PassManagerTraits<UnitType>,public AnalysisResolver{ friend SubPassClass; #else friend class PassManagerTraits<UnitType>::PassClass; - friend class PassManagerTraits<UnitType>::SubPassClass; + friend class PassManagerTraits<UnitType>::SubPassClass; #endif friend class PassManagerTraits<UnitType>; friend class ImmutablePass; @@ -219,7 +219,7 @@ public: // Run all of the passes for (unsigned i = 0, e = Passes.size(); i < e; ++i) { PassClass *P = Passes[i]; - + PMDebug::PrintPassInformation(getDepth(), "Executing Pass", P, M); // Get information about what analyses the pass uses... @@ -236,7 +236,7 @@ public: P->AnalysisImpls.clear(); P->AnalysisImpls.reserve(AnUsage.getRequiredSet().size()); for (std::vector<const PassInfo *>::const_iterator - I = AnUsage.getRequiredSet().begin(), + I = AnUsage.getRequiredSet().begin(), E = AnUsage.getRequiredSet().end(); I != E; ++I) { Pass *Impl = getAnalysisOrNullUp(*I); if (Impl == 0) { @@ -353,7 +353,7 @@ public: const PassInfo *IPID = ImmutablePasses[i]->getPassInfo(); if (IPID == ID) return ImmutablePasses[i]; - + // This pass is the current implementation of all of the interfaces it // implements as well. // @@ -420,14 +420,14 @@ public: if (Parent) { Parent->markPassUsed(P, this); } else { - assert(getAnalysisOrNullUp(P) && + assert(getAnalysisOrNullUp(P) && dynamic_cast<ImmutablePass*>(getAnalysisOrNullUp(P)) && "Pass available but not found! " "Perhaps this is a module pass requiring a function pass?"); } } } - + // Return the number of parent PassManagers that exist virtual unsigned getDepth() const { if (Parent == 0) return 0; @@ -514,8 +514,8 @@ private: //const std::vector<AnalysisID> &ProvidedSet = AnUsage.getProvidedSet(); if (Batcher /*&& ProvidedSet.empty()*/) closeBatcher(); // This pass cannot be batched! - - // Set the Resolver instance variable in the Pass so that it knows where to + + // Set the Resolver instance variable in the Pass so that it knows where to // find this object... // setAnalysisResolver(P, this); @@ -559,7 +559,7 @@ private: // For now assume that our results are never used... LastUseOf[P] = P; } - + // For FunctionPass subclasses, we must be sure to batch the FunctionPass's // together in a BatcherClass object so that all of the analyses are run // together a function at a time. @@ -588,7 +588,7 @@ public: return; } - // Set the Resolver instance variable in the Pass so that it knows where to + // Set the Resolver instance variable in the Pass so that it knows where to // find this object... // setAnalysisResolver(IP, this); @@ -601,7 +601,7 @@ public: // IP->AnalysisImpls.clear(); IP->AnalysisImpls.reserve(AU.getRequiredSet().size()); - for (std::vector<const PassInfo *>::const_iterator + for (std::vector<const PassInfo *>::const_iterator I = AU.getRequiredSet().begin(), E = AU.getRequiredSet().end(); I != E; ++I) { Pass *Impl = getAnalysisOrNullUp(*I); @@ -616,7 +616,7 @@ public: } IP->AnalysisImpls.push_back(std::make_pair(*I, Impl)); } - + // Initialize the immutable pass... IP->initializePass(); } @@ -642,7 +642,7 @@ public: typedef PassManagerT<Module> SubPassClass; // BatcherClass - The type to use for collation of subtypes... This class is - // never instantiated for the PassManager<BasicBlock>, but it must be an + // never instantiated for the PassManager<BasicBlock>, but it must be an // instance of PassClass to typecheck. // typedef PassClass BatcherClass; diff --git a/lib/VMCore/SymbolTable.cpp b/lib/VMCore/SymbolTable.cpp index 0881c41896..3290fbd37a 100644 --- a/lib/VMCore/SymbolTable.cpp +++ b/lib/VMCore/SymbolTable.cpp @@ -1,11 +1,11 @@ //===-- SymbolTable.cpp - Implement the SymbolTable class -----------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and revised by Reid -// Spencer. It is distributed under the University of Illinois Open Source +// Spencer. It is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the SymbolTable class for the VMCore library. @@ -31,7 +31,7 @@ SymbolTable::~SymbolTable() { cast<DerivedType>(TI->second)->removeAbstractTypeUser(this); } - // TODO: FIXME: BIG ONE: This doesn't unreference abstract types for the + // TODO: FIXME: BIG ONE: This doesn't unreference abstract types for the // planes that could still have entries! #ifndef NDEBUG // Only do this in -g mode... @@ -45,7 +45,7 @@ SymbolTable::~SymbolTable() { LeftoverValues = false; } } - + assert(LeftoverValues && "Values remain in symbol table!"); #endif } @@ -194,7 +194,7 @@ void SymbolTable::insertEntry(const std::string &Name, const Type *VTy, #if DEBUG_SYMBOL_TABLE dump(); - std::cerr << " Inserting definition: " << Name << ": " + std::cerr << " Inserting definition: " << Name << ": " << VTy->getDescription() << "\n"; #endif @@ -243,7 +243,7 @@ void SymbolTable::insert(const std::string& Name, const Type* T) { #if DEBUG_SYMBOL_TABLE dump(); - std::cerr << " Inserting type: " << UniqueName << ": " + std::cerr << " Inserting type: " << UniqueName << ": " << T->getDescription() << "\n"; #endif @@ -282,7 +282,7 @@ bool SymbolTable::strip() { remove(TI++); RemovedSymbol = true; } - + return RemovedSymbol; } @@ -299,7 +299,7 @@ void SymbolTable::refineAbstractType(const DerivedType *OldType, plane_iterator NewTypeIt = pmap.find(NewType); if (NewTypeIt == pmap.end()) { // If no plane exists, add one NewTypeIt = pmap.insert(make_pair(NewType, ValueMap())).first; - + if (NewType->isAbstract()) { cast<DerivedType>(NewType)->addAbstractTypeUser(this); #if DEBUG_ABSTYPE @@ -338,7 +338,7 @@ void SymbolTable::refineAbstractType(const DerivedType *OldType, // Ok we have two external global values. Make all uses of the new // one use the old one... NewGV->uncheckedReplaceAllUsesWith(ExistGV); - + // Update NewGV's name, we're about the remove it from the symbol // table. NewGV->Name = ""; @@ -387,7 +387,7 @@ void SymbolTable::refineAbstractType(const DerivedType *OldType, std::cerr << "Removing type " << OldType->getDescription() << "\n"; #endif OldType->removeAbstractTypeUser(this); - + I->second = (Type*)NewType; // TODO FIXME when types aren't const if (NewType->isAbstract()) { #if DEBUG_ABSTYPE diff --git a/lib/VMCore/SymbolTableListTraitsImpl.h b/lib/VMCore/SymbolTableListTraitsImpl.h index 22d2e1d6c7..6d70401c89 100644 --- a/lib/VMCore/SymbolTableListTraitsImpl.h +++ b/lib/VMCore/SymbolTableListTraitsImpl.h @@ -1,10 +1,10 @@ //===-- llvm/SymbolTableListTraitsImpl.h - Implementation ------*- C++ -*--===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the stickier parts of the SymbolTableListTraits class, diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 2bcda46161..3e5757b114 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -1,10 +1,10 @@ //===-- Type.cpp - Implement the Type class -------------------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the Type class for the VMCore library. @@ -103,13 +103,13 @@ const Type *Type::getUnsignedVersion() const { switch (getTypeID()) { default: assert(isInteger()&&"Type::getUnsignedVersion is only valid for integers!"); - case Type::UByteTyID: + case Type::UByteTyID: case Type::SByteTyID: return Type::UByteTy; - case Type::UShortTyID: + case Type::UShortTyID: case Type::ShortTyID: return Type::UShortTy; - case Type::UIntTyID: + case Type::UIntTyID: case Type::IntTyID: return Type::UIntTy; - case Type::ULongTyID: + case Type::ULongTyID: case Type::LongTyID: return Type::ULongTy; } } @@ -120,13 +120,13 @@ const Type *Type::getSignedVersion() const { switch (getTypeID()) { default: assert(isInteger() && "Type::getSignedVersion is only valid for integers!"); - case Type::UByteTyID: + case Type::UByteTyID: case Type::SByteTyID: return Type::SByteTy; - case Type::UShortTyID: + case Type::UShortTyID: case Type::ShortTyID: return Type::ShortTy; - case Type::UIntTyID: + case Type::UIntTyID: case Type::IntTyID: return Type::IntTy; - case Type::ULongTyID: + case Type::ULongTyID: case Type::LongTyID: return Type::LongTy; } } @@ -167,7 +167,7 @@ bool Type::isSizedDerivedType() const { /// algorithm for when a type is being forwarded to another type. const Type *Type::getForwardedTypeInternal() const { assert(ForwardType && "This type is not being forwarded to another type!"); - + // Check to see if the forwarded type has been forwarded on. If so, collapse // the forwarding links. const Type *RealForwardedType = ForwardType->getForwardedType(); @@ -181,7 +181,7 @@ const Type *Type::getForwardedTypeInternal() const { // Now drop the old reference. This could cause ForwardType to get deleted. cast<DerivedType>(ForwardType)->dropRef(); - + // Return the updated type. ForwardType = RealForwardedType; return ForwardType; @@ -201,28 +201,28 @@ static std::string getTypeDescription(const Type *Ty, AbstractTypeDescriptions.insert(std::make_pair(Ty, Desc)); return Desc; } - + if (!Ty->isAbstract()) { // Base case for the recursion std::map<const Type*, std::string>::iterator I = ConcreteTypeDescriptions.find(Ty); if (I != ConcreteTypeDescriptions.end()) return I->second; } - + // Check to see if the Type is already on the stack... unsigned Slot = 0, CurSize = TypeStack.size(); while (Slot < CurSize && TypeStack[Slot] != Ty) ++Slot; // Scan for type - - // This is another base case for the recursion. In this case, we know + + // This is another base case for the recursion. In this case, we know // that we have looped back to a type that we have previously visited. // Generate the appropriate upreference to handle this. - // + // if (Slot < CurSize) return "\\" + utostr(CurSize-Slot); // Here's the upreference // Recursive case: derived types... std::string Result; TypeStack.push_back(Ty); // Add us to the stack.. - + switch (Ty->getTypeID()) { case Type::FunctionTyID: { const FunctionType *FTy = cast<FunctionType>(Ty); @@ -289,7 +289,7 @@ static const std::string &getOrCreateDesc(std::map<const Type*,std::string>&Map, const Type *Ty) { std::map<const Type*, std::string>::iterator I = Map.find(Ty); if (I != Map.end()) return I->second; - + std::vector<const Type *> TypeStack; std::string Result = getTypeDescription(Ty, TypeStack); return Map[Ty] = Result; @@ -366,11 +366,11 @@ Type *Type::LabelTy = &TheLabelTy; //===----------------------------------------------------------------------===// FunctionType::FunctionType(const Type *Result, - const std::vector<const Type*> &Params, - bool IsVarArgs) : DerivedType(FunctionTyID), + const std::vector<const Type*> &Params, + bool IsVarArgs) : DerivedType(FunctionTyID), isVarArgs(IsVarArgs) { assert((Result->isFirstClassType() || Result == Type::VoidTy || - isa<OpaqueType>(Result)) && + isa<OpaqueType>(Result)) && "LLVM functions cannot return aggregates"); bool isAbstract = Result->isAbstract(); ContainedTys.reserve(Params.size()+1); @@ -415,7 +415,7 @@ PackedType::PackedType(const Type *ElType, unsigned NumEl) NumElements = NumEl; assert(NumEl > 0 && "NumEl of a PackedType must be greater than 0"); - assert((ElType->isIntegral() || ElType->isFloatingPoint()) && + assert((ElType->isIntegral() || ElType->isFloatingPoint()) && "Elements of a PackedType must be a primitive type"); } @@ -439,7 +439,7 @@ void DerivedType::dropAllTypeUses() { if (!ContainedTys.empty()) { while (ContainedTys.size() > 1) ContainedTys.pop_back(); - + // The type must stay abstract. To do this, we insert a pointer to a type // that will never get resolved, thus will always be abstract. static Type *AlwaysOpaqueTy = OpaqueType::get(); @@ -463,15 +463,15 @@ namespace llvm { template <> struct GraphTraits<TypePromotionGraph> { typedef Type NodeType; typedef Type::subtype_iterator ChildIteratorType; - + static inline NodeType *getEntryNode(TypePromotionGraph G) { return G.Ty; } - static inline ChildIteratorType child_begin(NodeType *N) { + static inline ChildIteratorType child_begin(NodeType *N) { if (N->isAbstract()) - return N->subtype_begin(); + return N->subtype_begin(); else // No need to process children of concrete types. - return N->subtype_end(); + return N->subtype_end(); } - static inline ChildIteratorType child_end(NodeType *N) { + static inline ChildIteratorType child_end(NodeType *N) { return N->subtype_end(); } }; @@ -507,12 +507,12 @@ void Type::PromoteAbstractToConcrete() { // abstract unless there is a non-SCC abstract type. if (std::find(SCC.begin(), SCC.end(), *CI) == SCC.end()) return; // Not going to be concrete, sorry. - + // Okay, we just discovered this whole SCC is now concrete, mark it as // such! for (unsigned i = 0, e = SCC.size(); i != e; ++i) { assert(SCC[i]->isAbstract() && "Why are we processing concrete types?"); - + SCC[i]->setAbstract(false); } @@ -606,7 +606,7 @@ static bool AbstractTypeHasCycleThrough(const Type *TargetTy, const Type *CurTy, if (!VisitedTypes.insert(CurTy).second) return false; // Already been here. - for (Type::subtype_iterator I = CurTy->subtype_begin(), + for (Type::subtype_iterator I = CurTy->subtype_begin(), E = CurTy->subtype_end(); I != E; ++I) if (AbstractTypeHasCycleThrough(TargetTy, *I, VisitedTypes)) return true; @@ -620,7 +620,7 @@ static bool ConcreteTypeHasCycleThrough(const Type *TargetTy, const Type *CurTy, if (!VisitedTypes.insert(CurTy).second) return false; // Already been here. - for (Type::subtype_iterator I = CurTy->subtype_begin(), + for (Type::subtype_iterator I = CurTy->subtype_begin(), E = CurTy->subtype_end(); I != E; ++I) if (ConcreteTypeHasCycleThrough(TargetTy, *I, VisitedTypes)) return true; @@ -633,7 +633,7 @@ static bool TypeHasCycleThroughItself(const Type *Ty) { std::set<const Type*> VisitedTypes; if (Ty->isAbstract()) { // Optimized case for abstract types. - for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); + for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); I != E; ++I) if (AbstractTypeHasCycleThrough(Ty, *I, VisitedTypes)) return true; @@ -670,7 +670,7 @@ class TypeMap { private: void clear(std::vector<Type *> &DerivedTypes) { - for (typename std::map<ValType, PATypeHolder>::iterator I = Map.begin(), + for (typename std::map<ValType, PATypeHolder>::iterator I = Map.begin(), E = Map.end(); I != E; ++I) DerivedTypes.push_back(I->second.get()); TypesByHash.clear(); @@ -694,7 +694,7 @@ public: } void RemoveFromTypesByHash(unsigned Hash, const Type *Ty) { - std::multimap<unsigned, PATypeHolder>::iterator I = + std::multimap<unsigned, PATypeHolder>::iterator I = TypesByHash.lower_bound(Hash); while (I->second != Ty) { ++I; @@ -736,7 +736,7 @@ public: } unsigned TypeHash = ValType::hashTypeStructure(Ty); - + // If there are no cycles going through this node, we can do a simple, // efficient lookup in the map, instead of an inefficient nasty linear // lookup. @@ -756,7 +756,7 @@ public: Ty->refineAbstractTypeTo(NewTy); return; } - + } else { // Now we check to see if there is an existing entry in the table which is // structurally identical to the newly refined type. If so, this type @@ -770,7 +770,7 @@ public: if (TypesEqual(Ty, I->second)) { assert(Ty->isAbstract() && "Replacing a non-abstract type?"); TypeClass *NewTy = cast<TypeClass>((Type*)I->second.get()); - + if (Entry == E) { // Find the location of Ty in the TypesByHash structure. while (I->second != Ty) { @@ -785,7 +785,7 @@ public: return; } } else { - // Remember the position of + // Remember the position of Entry = I; } } @@ -807,14 +807,14 @@ public: if (Ty->isAbstract()) Ty->PromoteAbstractToConcrete(); } - + void print(const char *Arg) const { #ifdef DEBUG_MERGE_TYPES std::cerr << "TypeMap<>::" << Arg << " table contents:\n"; unsigned i = 0; for (typename std::map<ValType, PATypeHolder>::const_iterator I = Map.begin(), E = Map.end(); I != E; ++I) - std::cerr << " " << (++i) << ". " << (void*)I->second.get() << " " + std::cerr << " " << (++i) << ". " << (void*)I->second.get() << " " << *I->second.get() << "\n"; #endif } @@ -879,7 +879,7 @@ FunctionValType FunctionValType::get(const FunctionType *FT) { // FunctionType::get - The factory function for the FunctionType class... -FunctionType *FunctionType::get(const Type *ReturnType, +FunctionType *FunctionType::get(const Type *ReturnType, const std::vector<const Type*> &Params, bool isVarArg) { FunctionValType VT(ReturnType, Params, isVarArg); @@ -1010,7 +1010,7 @@ public: ElTypes.reserve(ST->getNumElements()); for (unsigned i = 0, e = ST->getNumElements(); i != e; ++i) ElTypes.push_back(ST->getElementType(i)); - + return StructValType(ElTypes); } @@ -1121,12 +1121,12 @@ void DerivedType::removeAbstractTypeUser(AbstractTypeUser *U) const { assert(i < AbstractTypeUsers.size() && "Index out of range!"); // Wraparound? AbstractTypeUsers.erase(AbstractTypeUsers.begin()+i); - + #ifdef DEBUG_MERGE_TYPES std::cerr << " remAbstractTypeUser[" << (void*)this << ", " << *this << "][" << i << "] User = " << U << "\n"; #endif - + if (AbstractTypeUsers.empty() && getRefCount() == 0 && isAbstract()) { #ifdef DEBUG_MERGE_TYPES std::cerr << "DELETEing unused abstract type: <" << *this @@ -1223,7 +1223,7 @@ void DerivedType::notifyUsesThatTypeBecameConcrete() { "AbstractTypeUser did not remove itself from the use list!"); } } - + @@ -1333,7 +1333,7 @@ void Type::clearAllTypeMaps() { ArrayTypes.clear(DerivedTypes); PackedTypes.clear(DerivedTypes); - for(std::vector<Type *>::iterator I = DerivedTypes.begin(), + for(std::vector<Type *>::iterator I = DerivedTypes.begin(), E = DerivedTypes.end(); I != E; ++I) (*I)->ContainedTys.clear(); for(std::vector<Type *>::iterator I = DerivedTypes.begin(), diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index dd06441a95..f59e8ef957 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -1,13 +1,13 @@ //===-- Value.cpp - Implement the Value class -----------------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // -// This file implements the Value and User classes. +// This file implements the Value and User classes. // //===----------------------------------------------------------------------===// @@ -34,7 +34,7 @@ Value::Value(const Type *ty, unsigned scid, const std::string &name) : SubclassID(scid), SubclassData(0), Ty(checkType(ty)), UseList(0), Name(name) { if (!isa<Constant>(this) && !isa<BasicBlock>(this)) - assert((Ty->isFirstClassType() || Ty == Type::VoidTy || + assert((Ty->isFirstClassType() || Ty == Type::VoidTy || isa<OpaqueType>(ty)) && "Cannot create non-first-class values except for constants!"); if (ty == Type::VoidTy) @@ -46,7 +46,7 @@ Value::~Value() { // Check to make sure that there are no uses of this value that are still // around when the value is destroyed. If there are, then we have a dangling // reference and something is wrong. This code is here to print out what is - // still being referenced. The value in question should be printed as + // still being referenced. The value in question should be printed as // a <badref> // if (use_begin() != use_end()) { @@ -142,7 +142,7 @@ void Value::uncheckedReplaceAllUsesWith(Value *New) { if (Constant *C = dyn_cast<Constant>(U.getUser())) { if (!isa<GlobalValue>(C)) C->replaceUsesOfWithOnConstant(this, New, true); - else + else U.set(New); } else { U.set(New); diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 3964817f82..da14c00065 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -1,10 +1,10 @@ //===-- Verifier.cpp - Implement the Module Verifier -------------*- C++ -*-==// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file defines the function verifier interface, that can be used for some @@ -76,17 +76,17 @@ namespace { // Anonymous namespace for class /// an instruction in the same block. std::set<Instruction*> InstsInThisBlock; - Verifier() + Verifier() : Broken(false), RealPass(true), action(AbortProcessAction), DS(0), msgs( std::ios::app | std::ios::out ) {} Verifier( VerifierFailureAction ctn ) - : Broken(false), RealPass(true), action(ctn), DS(0), + : Broken(false), RealPass(true), action(ctn), DS(0), msgs( std::ios::app | std::ios::out ) {} - Verifier(bool AB ) - : Broken(false), RealPass(true), - action( AB ? AbortProcessAction : PrintMessageAction), DS(0), + Verifier(bool AB ) + : Broken(false), RealPass(true), + action( AB ? AbortProcessAction : PrintMessageAction), DS(0), msgs( std::ios::app | std::ios::out ) {} - Verifier(DominatorSet &ds) + Verifier(DominatorSet &ds) : Broken(false), RealPass(false), action(PrintMessageAction), DS(&ds), msgs( std::ios::app | std::ios::out ) {} @@ -223,7 +223,7 @@ namespace { // Anonymous namespace for class Broken = true; } - void CheckFailed( const std::string& Message, const Value* V1, + void CheckFailed( const std::string& Message, const Value* V1, const Type* T2, const Value* V3 = 0 ) { msgs << Message << "\n"; WriteValue(V1); @@ -264,11 +264,11 @@ void Verifier::visitGlobalValue(GlobalValue &GV) { } void Verifier::visitGlobalVariable(GlobalVariable &GV) { - if (GV.hasInitializer()) + if (GV.hasInitializer()) Assert1(GV.getInitializer()->getType() == GV.getType()->getElementType(), "Global variable initializer type does not match global " "variable type!", &GV); - + visitGlobalValue(GV); } @@ -278,7 +278,7 @@ void Verifier::visitGlobalVariable(GlobalVariable &GV) { void Verifier::verifySymbolTable(SymbolTable &ST) { // Loop over all of the values in all type planes in the symbol table. - for (SymbolTable::plane_const_iterator PI = ST.plane_begin(), + for (SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE = ST.plane_end(); PI != PE; ++PI) for (SymbolTable::value_const_iterator VI = PI->second.begin(), VE = PI->second.end(); VI != VE; ++VI) { @@ -312,7 +312,7 @@ void Verifier::visitFunction(Function &F) { "Argument value does not match function argument type!", I, FT->getParamType(i)); // Make sure no aggregates are passed by value. - Assert1(I->getType()->isFirstClassType(), + Assert1(I->getType()->isFirstClassType(), "Functions cannot take aggregates as arguments by value!", I); } @@ -340,7 +340,7 @@ void Verifier::visitBasicBlock(BasicBlock &BB) { if (isa<PHINode>(BB.front())) { std::vector<BasicBlock*> Preds(pred_begin(&BB), pred_end(&BB)); std::sort(Preds.begin(), Preds.end()); - PHINode *PN; + PHINode *PN; for (BasicBlock::iterator I = BB.begin(); (PN = dyn_cast<PHINode>(I));++I) { // Ensure that PHI nodes have at least one entry! @@ -350,7 +350,7 @@ void Verifier::visitBasicBlock(BasicBlock &BB) { Assert1(PN->getNumIncomingValues() == Preds.size(), "PHINode should have one entry for each predecessor of its " "parent basic block!", PN); - + // Get and sort all incoming values in the PHI node... std::vector<std::pair<BasicBlock*, Value*> > Values; Values.reserve(PN->getNumIncomingValues()); @@ -358,7 +358,7 @@ void Verifier::visitBasicBlock(BasicBlock &BB) { Values.push_back(std::make_pair(PN->getIncomingBlock(i), PN->getIncomingValue(i))); std::sort(Values.begin(), Values.end()); - + for (unsigned i = 0, e = Values.size(); i != e; ++i) { // Check to make sure that if there is more than one entry for a // particular basic block in this PHI node, that the incoming values are @@ -369,12 +369,12 @@ void Verifier::visitBasicBlock(BasicBlock &BB) { "PHI node has multiple entries for the same basic block with " "different incoming values!", PN, Values[i].first, Values[i].second, Values[i-1].second); - + // Check to make sure that the predecessors and PHI node entries are // matched up. Assert3(Values[i].first == Preds[i], "PHI node entries do not match predecessors!", PN, - Values[i].first, Preds[i]); + Values[i].first, Preds[i]); } } } @@ -509,11 +509,11 @@ void Verifier::visitBinaryOperator(BinaryOperator &B) { Assert1(B.getType() == B.getOperand(0)->getType(), "Arithmetic operators must have same type for operands and result!", &B); - Assert1(B.getType()->isInteger() || B.getType()->isFloatingPoint() || + Assert1(B.getType()->isInteger() || B.getType()->isFloatingPoint() || isa<PackedType>(B.getType()), "Arithmetic operators must have integer, fp, or packed type!", &B); } - + visitInstruction(B); } @@ -557,7 +557,7 @@ void Verifier::visitStoreInst(StoreInst &SI) { /// verifyInstruction - Verify that an instruction is well formed. /// void Verifier::visitInstruction(Instruction &I) { - BasicBlock *BB = I.getParent(); + BasicBlock *BB = I.getParent(); Assert1(BB, "Instruction not embedded in basic block!", &I); if (!isa<PHINode>(I)) { // Check that non-phi nodes are not self referential @@ -749,13 +749,13 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { case Intrinsic::memset: NumArgs = 4; break; case Intrinsic::prefetch: NumArgs = 3; break; - case Intrinsic::pcmarker: - NumArgs = 1; + case Intrinsic::pcmarker: + NumArgs = 1; Assert1(isa<Constant>(CI.getOperand(1)), "First argument to llvm.pcmarker must be a constant!", &CI); break; - - case Intrinsic::not_intrinsic: + + case Intrinsic::not_intrinsic: assert(0 && "Invalid intrinsic!"); NumArgs = 0; break; } @@ -774,11 +774,11 @@ FunctionPass *llvm::createVerifierPass(VerifierFailureAction action) { } -// verifyFunction - Create +// verifyFunction - Create bool llvm::verifyFunction(const Function &f, VerifierFailureAction action) { Function &F = const_cast<Function&>(f); assert(!F.isExternal() && "Cannot verify external functions"); - + FunctionPassManager FPM(new ExistingModuleProvider(F.getParent())); Verifier *V = new Verifier(action); FPM.add(V); |