Finegrainify namespacification
authorChris Lattner <sabre@nondot.org>
Fri, 9 Jan 2004 06:12:26 +0000 (06:12 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 9 Jan 2004 06:12:26 +0000 (06:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10727 91177308-0d34-0410-b5e6-96231b3b80d8

17 files changed:
lib/Linker/LinkModules.cpp
lib/Transforms/Hello/Hello.cpp
lib/Transforms/Instrumentation/BlockProfiling.cpp
lib/Transforms/Instrumentation/TraceValues.cpp
lib/Transforms/Utils/BasicBlockUtils.cpp
lib/Transforms/Utils/BreakCriticalEdges.cpp
lib/Transforms/Utils/CloneFunction.cpp
lib/Transforms/Utils/CloneModule.cpp
lib/Transforms/Utils/CloneTrace.cpp
lib/Transforms/Utils/DemoteRegToStack.cpp
lib/Transforms/Utils/InlineFunction.cpp
lib/Transforms/Utils/Linker.cpp
lib/Transforms/Utils/PromoteMemoryToRegister.cpp
lib/Transforms/Utils/SimplifyCFG.cpp
lib/Transforms/Utils/ValueMapper.cpp
lib/Transforms/Utils/ValueMapper.h
lib/VMCore/Linker.cpp

index bdbdb7d4ccc263e9ae855387dc375ed005616e2f..af430bd70b795992cfccb934758df5213c82e8a4 100644 (file)
@@ -23,8 +23,7 @@
 #include "llvm/SymbolTable.h"
 #include "llvm/iOther.h"
 #include "llvm/Assembly/Writer.h"
-
-namespace llvm {
+using namespace llvm;
 
 // Error - Simple wrapper function to conditionally assign to E and return true.
 // This just makes error return conditions a little bit simpler...
@@ -842,7 +841,7 @@ static bool LinkAppendingVars(Module *M,
 // the problem.  Upon failure, the Dest module could be in a modified state, and
 // shouldn't be relied on to be consistent.
 //
-bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
+bool llvm::LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
   if (Dest->getEndianness() == Module::AnyEndianness)
     Dest->setEndianness(Src->getEndianness());
   if (Dest->getPointerSize() == Module::AnyPointerSize)
@@ -909,4 +908,3 @@ bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
   return false;
 }
 
-} // End llvm namespace
index 4ed281a40afce43e16746365660935f7a4d17a89..b6262118efa9becc67edafcdbd479c30d662bd71 100644 (file)
@@ -14,8 +14,7 @@
 
 #include "llvm/Pass.h"
 #include "llvm/Function.h"
-
-namespace llvm {
+using namespace llvm;
 
 namespace {
   // Hello - The first implementation, without getAnalysisUsage.
@@ -41,5 +40,3 @@ namespace {
   }; 
   RegisterOpt<Hello2> Y("hello2", "Hello World Pass (with getAnalysisUsage implemented)");
 }
-
-} // End llvm namespace
index 90ef14df7ecb9cd1ee509d8df2c394cbacc25db0..7b38d70d9e377ed26e35697a7156849874c31324 100644 (file)
@@ -24,8 +24,7 @@
 #include "llvm/Instructions.h"
 #include "llvm/Module.h"
 #include "llvm/Pass.h"
-
-namespace llvm {
+using namespace llvm;
 
 static void insertInitializationCall(Function *MainFn, const char *FnName,
                                      GlobalValue *Array) {
@@ -184,4 +183,3 @@ bool BlockProfiler::run(Module &M) {
   return true;
 }
 
-} // End llvm namespace
index c802f736046c6e5144d394acecda893e85019c82..30904a627e6924d18c43738acb9b7e46e6af3a81 100644 (file)
@@ -25,8 +25,7 @@
 #include "Support/StringExtras.h"
 #include <algorithm>
 #include <sstream>
-
-namespace llvm {
+using namespace llvm;
 
 static cl::opt<bool>
 DisablePtrHashing("tracedisablehashdisable", cl::Hidden,
@@ -112,11 +111,11 @@ namespace {
 } // end anonymous namespace
 
 
-Pass *createTraceValuesPassForFunction() {     // Just trace functions
+Pass *llvm::createTraceValuesPassForFunction() {     // Just trace functions
   return new FunctionTracer();
 }
 
-Pass *createTraceValuesPassForBasicBlocks() {  // Trace BB's and functions
+Pass *llvm::createTraceValuesPassForBasicBlocks() {  // Trace BB's and functions
   return new BasicBlockTracer();
 }
 
@@ -435,5 +434,3 @@ bool InsertTraceCode::runOnFunction(Function &F) {
   
   return true;
 }
-
-} // End llvm namespace
index 5fb5469332538e1f2a89e2f6d469af43c6f56691..945e15fd0b9dd9b090d157aa47b7ebabcca898a2 100644 (file)
 #include "llvm/Constant.h"
 #include "llvm/Type.h"
 #include <algorithm>
-
-namespace llvm {
+using namespace llvm;
 
 // ReplaceInstWithValue - Replace all uses of an instruction (specified by BI)
 // with a value, then remove and delete the original instruction.
 //
-void ReplaceInstWithValue(BasicBlock::InstListType &BIL,
-                          BasicBlock::iterator &BI, Value *V) {
+void llvm::ReplaceInstWithValue(BasicBlock::InstListType &BIL,
+                                BasicBlock::iterator &BI, Value *V) {
   Instruction &I = *BI;
   // Replaces all of the uses of the instruction with uses of the value
   I.replaceAllUsesWith(V);
@@ -45,8 +44,8 @@ void ReplaceInstWithValue(BasicBlock::InstListType &BIL,
 // instruction specified by I.  The original instruction is deleted and BI is
 // updated to point to the new instruction.
 //
-void ReplaceInstWithInst(BasicBlock::InstListType &BIL,
-                         BasicBlock::iterator &BI, Instruction *I) {
+void llvm::ReplaceInstWithInst(BasicBlock::InstListType &BIL,
+                               BasicBlock::iterator &BI, Instruction *I) {
   assert(I->getParent() == 0 &&
          "ReplaceInstWithInst: Instruction already inserted into basic block!");
 
@@ -63,7 +62,7 @@ void ReplaceInstWithInst(BasicBlock::InstListType &BIL,
 // ReplaceInstWithInst - Replace the instruction specified by From with the
 // instruction specified by To.
 //
-void ReplaceInstWithInst(Instruction *From, Instruction *To) {
+void llvm::ReplaceInstWithInst(Instruction *From, Instruction *To) {
   BasicBlock::iterator BI(From);
   ReplaceInstWithInst(From->getParent()->getInstList(), BI, To);
 }
@@ -75,7 +74,7 @@ void ReplaceInstWithInst(Instruction *From, Instruction *To) {
 // deleted, a return instruction is inserted in its place which can cause a
 // surprising change in program behavior if it is not expected.
 //
-void RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum) {
+void llvm::RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum) {
   assert(SuccNum < TI->getNumSuccessors() &&
          "Trying to remove a nonexistant successor!");
 
@@ -115,4 +114,3 @@ void RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum) {
     ReplaceInstWithInst(TI, NewTI);
 }
 
-} // End llvm namespace
index 1175b1053b2d386dace2552c1d4c33d5a6ed02a4..178e8ca1957c468b4fd7a126b566eaf56f99233e 100644 (file)
@@ -24,8 +24,7 @@
 #include "llvm/iPHINode.h"
 #include "llvm/Support/CFG.h"
 #include "Support/Statistic.h"
-
-namespace llvm {
+using namespace llvm;
 
 namespace {
   Statistic<> NumBroken("break-crit-edges", "Number of blocks inserted");
@@ -49,8 +48,8 @@ namespace {
 }
 
 // Publically exposed interface to pass...
-const PassInfo *BreakCriticalEdgesID = X.getPassInfo();
-Pass *createBreakCriticalEdgesPass() { return new BreakCriticalEdges(); }
+const PassInfo *llvm::BreakCriticalEdgesID = X.getPassInfo();
+Pass *llvm::createBreakCriticalEdgesPass() { return new BreakCriticalEdges(); }
 
 // runOnFunction - Loop over all of the edges in the CFG, breaking critical
 // edges as they are found.
@@ -78,7 +77,7 @@ bool BreakCriticalEdges::runOnFunction(Function &F) {
 // Critical edges are edges from a block with multiple successors to a block
 // with multiple predecessors.
 //
-bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum) {
+bool llvm::isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum) {
   assert(SuccNum < TI->getNumSuccessors() && "Illegal edge specification!");
   if (TI->getNumSuccessors() == 1) return false;
 
@@ -97,7 +96,7 @@ bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum) {
 // calling this pass will not invalidate either of them.  This returns true if
 // the edge was split, false otherwise.
 //
-bool SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
+bool llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
   if (!isCriticalEdge(TI, SuccNum)) return false;
   BasicBlock *TIBB = TI->getParent();
   BasicBlock *DestBB = TI->getSuccessor(SuccNum);
@@ -169,5 +168,3 @@ bool SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
   }
   return true;
 }
-
-} // End llvm namespace
index d8aa9aebe43bcafd66385f7974c55a8336778bad..17ad8c5175d3fa2b1e80fa01ad99582bba53aea2 100644 (file)
@@ -18,8 +18,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Function.h"
 #include "ValueMapper.h"
-
-namespace llvm {
+using namespace llvm;
 
 // RemapInstruction - Convert the instruction operands from referencing the 
 // current values into those specified by ValueMap.
@@ -41,9 +40,9 @@ static inline void RemapInstruction(Instruction *I,
 }
 
 // CloneBasicBlock - See comments in Cloning.h
-BasicBlock *CloneBasicBlock(const BasicBlock *BB,
-                            std::map<const Value*, Value*> &ValueMap,
-                            const char *NameSuffix) {
+BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB,
+                                  std::map<const Value*, Value*> &ValueMap,
+                                  const char *NameSuffix) {
   BasicBlock *NewBB = new BasicBlock("");
   if (BB->hasName()) NewBB->setName(BB->getName()+NameSuffix);
 
@@ -62,10 +61,10 @@ BasicBlock *CloneBasicBlock(const BasicBlock *BB,
 // Clone OldFunc into NewFunc, transforming the old arguments into references to
 // ArgMap values.
 //
-void CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
-                       std::map<const Value*, Value*> &ValueMap,
-                       std::vector<ReturnInst*> &Returns,
-                       const char *NameSuffix) {
+void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
+                             std::map<const Value*, Value*> &ValueMap,
+                             std::vector<ReturnInst*> &Returns,
+                             const char *NameSuffix) {
   assert(NameSuffix && "NameSuffix cannot be null!");
   
 #ifndef NDEBUG
@@ -112,8 +111,8 @@ void CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
 /// updated to include mappings from all of the instructions and basicblocks in
 /// the function from their old to new values.
 ///
-Function *CloneFunction(const Function *F,
-                        std::map<const Value*, Value*> &ValueMap) {
+Function *llvm::CloneFunction(const Function *F,
+                              std::map<const Value*, Value*> &ValueMap) {
   std::vector<const Type*> ArgTypes;
 
   // The user might be deleting arguments to the function by specifying them in
@@ -143,4 +142,3 @@ Function *CloneFunction(const Function *F,
   return NewF;                    
 }
 
-} // End llvm namespace
index 21a8675f07b9595229e4e1e87021890ad836b241..f8ee99b30699b5f5562a544592273fe677deb198 100644 (file)
 #include "llvm/SymbolTable.h"
 #include "llvm/Constant.h"
 #include "ValueMapper.h"
-
-namespace llvm {
+using namespace llvm;
 
 /// CloneModule - Return an exact copy of the specified module.  This is not as
 /// easy as it might seem because we have to worry about making copies of global
 /// variables and functions, and making their (initializers and references,
 /// respectively) refer to the right globals.
 ///
-Module *CloneModule(const Module *M) {
+Module *llvm::CloneModule(const Module *M) {
   // First off, we need to create the new module...
   Module *New = new Module(M->getModuleIdentifier());
   New->setEndianness(M->getEndianness());
@@ -90,5 +89,3 @@ Module *CloneModule(const Module *M) {
 
   return New;
 }
-
-} // End llvm namespace
index 990e54c783b0230e4b84dd442aec436da30a3503..61186d38f9e9e1ed5528d3046b17214aae236c71 100644 (file)
 #include "llvm/Transforms/Utils/Cloning.h"
 #include "llvm/iPHINode.h"
 #include "llvm/Function.h"
-
-
-namespace llvm {
+using namespace llvm;
 
 //Clones the trace (a vector of basic blocks)
-std::vector<BasicBlock *> CloneTrace(const std::vector<BasicBlock*> &origTrace) {
-
+std::vector<BasicBlock *>
+llvm::CloneTrace(const std::vector<BasicBlock*> &origTrace) {
   std::vector<BasicBlock *> clonedTrace;
   std::map<const Value*, Value*> ValueMap;
   
@@ -88,5 +86,3 @@ std::vector<BasicBlock *> CloneTrace(const std::vector<BasicBlock*> &origTrace)
   //return new vector of basic blocks
   return clonedTrace;
 }
-
-} // End llvm namespace
index e35dca4de03100e03f4a87e8bf121ca34312a8dc..ec0b091f94c542959309e1a0bd5a2c6f3540d397 100644 (file)
 #include "llvm/iTerminators.h"
 #include "llvm/Type.h"
 #include "Support/hash_set"
-
-namespace llvm {
+using namespace llvm;
 
 typedef hash_set<PHINode*>           PhiSet;
 typedef hash_set<PHINode*>::iterator PhiSetIterator;
 
 // Helper function to push a phi *and* all its operands to the worklist!
 // Do not push an instruction if it is already in the result set of Phis to go.
-inline void PushOperandsOnWorkList(std::vector<Instruction*>& workList,
-                                   PhiSet& phisToGo, PHINode* phiN) {
+static inline void PushOperandsOnWorkList(std::vector<Instruction*>& workList,
+                                          PhiSet& phisToGo, PHINode* phiN) {
   for (User::op_iterator OI = phiN->op_begin(), OE = phiN->op_end();
        OI != OE; ++OI) {
     Instruction* opI = cast<Instruction>(OI);
@@ -133,7 +132,7 @@ static void AddLoadsAndStores(AllocaInst* XSlot, Instruction& X,
 //
 // Returns the pointer to the alloca inserted to create a stack slot for X.
 //
-AllocaInst* DemoteRegToStack(Instruction& X) {
+AllocaInst* llvm::DemoteRegToStack(Instruction& X) {
   if (X.getType() == Type::VoidTy)
     return 0;                             // nothing to do!
 
@@ -162,5 +161,3 @@ AllocaInst* DemoteRegToStack(Instruction& X) {
 
   return XSlot;
 }
-
-} // End llvm namespace
index a0fc9bf1cff128169fba0ebb35408afcc6c133ce..ef473becaa3bf1bf4d7f9a23cf3f41e58855c257 100644 (file)
 #include "llvm/Intrinsics.h"
 #include "llvm/Support/CallSite.h"
 #include "llvm/Transforms/Utils/Local.h"
+using namespace llvm;
 
-namespace llvm {
-
-bool InlineFunction(CallInst *CI) { return InlineFunction(CallSite(CI)); }
-bool InlineFunction(InvokeInst *II) { return InlineFunction(CallSite(II)); }
+bool llvm::InlineFunction(CallInst *CI) { return InlineFunction(CallSite(CI)); }
+bool llvm::InlineFunction(InvokeInst *II) {return InlineFunction(CallSite(II));}
 
 // InlineFunction - This function inlines the called function into the basic
 // block of the caller.  This returns false if it is not possible to inline this
@@ -38,7 +37,7 @@ bool InlineFunction(InvokeInst *II) { return InlineFunction(CallSite(II)); }
 // exists in the instruction stream.  Similiarly this will inline a recursive
 // function by one level.
 //
-bool InlineFunction(CallSite CS) {
+bool llvm::InlineFunction(CallSite CS) {
   Instruction *TheCall = CS.getInstruction();
   assert(TheCall->getParent() && TheCall->getParent()->getParent() &&
          "Instruction not in function!");
@@ -280,5 +279,3 @@ bool InlineFunction(CallSite CS) {
   SimplifyCFG(AfterCallBB);
   return true;
 }
-
-} // End llvm namespace
index bdbdb7d4ccc263e9ae855387dc375ed005616e2f..af430bd70b795992cfccb934758df5213c82e8a4 100644 (file)
@@ -23,8 +23,7 @@
 #include "llvm/SymbolTable.h"
 #include "llvm/iOther.h"
 #include "llvm/Assembly/Writer.h"
-
-namespace llvm {
+using namespace llvm;
 
 // Error - Simple wrapper function to conditionally assign to E and return true.
 // This just makes error return conditions a little bit simpler...
@@ -842,7 +841,7 @@ static bool LinkAppendingVars(Module *M,
 // the problem.  Upon failure, the Dest module could be in a modified state, and
 // shouldn't be relied on to be consistent.
 //
-bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
+bool llvm::LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
   if (Dest->getEndianness() == Module::AnyEndianness)
     Dest->setEndianness(Src->getEndianness());
   if (Dest->getPointerSize() == Module::AnyPointerSize)
@@ -909,4 +908,3 @@ bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
   return false;
 }
 
-} // End llvm namespace
index 0859f6998011197d793f2bf65865baa8ae8b111c..af4892fb915c736cda10360bf67aefb1cd303bdf 100644 (file)
 #include "llvm/Constant.h"
 #include "llvm/Support/CFG.h"
 #include "Support/StringExtras.h"
-
-namespace llvm {
+using namespace llvm;
 
 /// isAllocaPromotable - Return true if this alloca is legal for promotion.
 /// This is true if there are only loads and stores to the alloca...
 ///
-bool isAllocaPromotable(const AllocaInst *AI, const TargetData &TD) {
+bool llvm::isAllocaPromotable(const AllocaInst *AI, const TargetData &TD) {
   // FIXME: If the memory unit is of pointer or integer type, we can permit
   // assignments to subsections of the memory unit.
 
@@ -454,12 +453,10 @@ void PromoteMem2Reg::RenamePass(BasicBlock *BB, BasicBlock *Pred,
 /// use of DominanceFrontier information.  This function does not modify the CFG
 /// of the function at all.  All allocas must be from the same function.
 ///
-void PromoteMemToReg(const std::vector<AllocaInst*> &Allocas,
-                     DominatorTree &DT, DominanceFrontier &DF,
-                     const TargetData &TD) {
+void llvm::PromoteMemToReg(const std::vector<AllocaInst*> &Allocas,
+                           DominatorTree &DT, DominanceFrontier &DF,
+                           const TargetData &TD) {
   // If there is nothing to do, bail out...
   if (Allocas.empty()) return;
   PromoteMem2Reg(Allocas, DT, DF, TD).run();
 }
-
-} // End llvm namespace
index 158d9119ae5aa83aea42a0ba28c0cea039d59fbd..b827123e609c5137b86f6b67f9d3412b0cb1a005 100644 (file)
@@ -20,8 +20,7 @@
 #include "llvm/Support/CFG.h"
 #include <algorithm>
 #include <functional>
-
-namespace llvm {
+using namespace llvm;
 
 // PropagatePredecessors - This gets "Succ" ready to have the predecessors from
 // "BB".  This is a little tricky because "Succ" has PHI nodes, which need to
@@ -98,7 +97,7 @@ static bool PropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
 //
 // WARNING:  The entry node of a function may not be simplified.
 //
-bool SimplifyCFG(BasicBlock *BB) {
+bool llvm::SimplifyCFG(BasicBlock *BB) {
   bool Changed = false;
   Function *M = BB->getParent();
 
@@ -300,5 +299,3 @@ bool SimplifyCFG(BasicBlock *BB) {
   
   return Changed;
 }
-
-} // End llvm namespace
index 248ebace7a5cf7656cd693160ca85dac5506bdf9..40dd58a146133ac4c139c6a16466b135b5370268 100644 (file)
 #include "ValueMapper.h"
 #include "llvm/Constants.h"
 #include "llvm/Instruction.h"
+using namespace llvm;
 
-namespace llvm {
-
-Value *MapValue(const Value *V, std::map<const Value*, Value*> &VM) {
+Value *llvm::MapValue(const Value *V, std::map<const Value*, Value*> &VM) {
   Value *&VMSlot = VM[V];
   if (VMSlot) return VMSlot;      // Does it exist in the map yet?
   
@@ -106,5 +105,3 @@ Value *MapValue(const Value *V, std::map<const Value*, Value*> &VM) {
   assert(0 && "Unknown value type: why didn't it get resolved?!");
   return 0;
 }
-
-} // End llvm namespace
index e67b3261dba85da0f08c1f3aaee978a2c9c994b2..941a8b3c5db69d70dcd8b4f170c45660a9b7f380 100644 (file)
 #include <map>
 
 namespace llvm {
-
-class Value;
-
-Value *MapValue(const Value *V, std::map<const Value*, Value*> &VM);
-
+  class Value;
+  Value *MapValue(const Value *V, std::map<const Value*, Value*> &VM);
 } // End llvm namespace
 
 #endif
index bdbdb7d4ccc263e9ae855387dc375ed005616e2f..af430bd70b795992cfccb934758df5213c82e8a4 100644 (file)
@@ -23,8 +23,7 @@
 #include "llvm/SymbolTable.h"
 #include "llvm/iOther.h"
 #include "llvm/Assembly/Writer.h"
-
-namespace llvm {
+using namespace llvm;
 
 // Error - Simple wrapper function to conditionally assign to E and return true.
 // This just makes error return conditions a little bit simpler...
@@ -842,7 +841,7 @@ static bool LinkAppendingVars(Module *M,
 // the problem.  Upon failure, the Dest module could be in a modified state, and
 // shouldn't be relied on to be consistent.
 //
-bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
+bool llvm::LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
   if (Dest->getEndianness() == Module::AnyEndianness)
     Dest->setEndianness(Src->getEndianness());
   if (Dest->getPointerSize() == Module::AnyPointerSize)
@@ -909,4 +908,3 @@ bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) {
   return false;
 }
 
-} // End llvm namespace