[llvm-commits] CVS: llvm/lib/Transforms/Utils/BasicBlockUtils.cpp BreakCriticalEdges.cpp CloneFunction.cpp CloneModule.cpp CloneTrace.cpp DemoteRegToStack.cpp InlineFunction.cpp Linker.cpp PromoteMemoryToRegister.cpp SimplifyCFG.cpp ValueMapper.cpp ValueMapper.h

Chris Lattner lattner at cs.uiuc.edu
Fri Jan 9 00:13:14 PST 2004


Changes in directory llvm/lib/Transforms/Utils:

BasicBlockUtils.cpp updated: 1.9 -> 1.10
BreakCriticalEdges.cpp updated: 1.17 -> 1.18
CloneFunction.cpp updated: 1.18 -> 1.19
CloneModule.cpp updated: 1.8 -> 1.9
CloneTrace.cpp updated: 1.4 -> 1.5
DemoteRegToStack.cpp updated: 1.7 -> 1.8
InlineFunction.cpp updated: 1.17 -> 1.18
Linker.cpp updated: 1.64 -> 1.65
PromoteMemoryToRegister.cpp updated: 1.57 -> 1.58
SimplifyCFG.cpp updated: 1.18 -> 1.19
ValueMapper.cpp updated: 1.8 -> 1.9
ValueMapper.h updated: 1.3 -> 1.4

---
Log message:

Finegrainify namespacification


---
Diffs of the changes:  (+48 -82)

Index: llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
diff -u llvm/lib/Transforms/Utils/BasicBlockUtils.cpp:1.9 llvm/lib/Transforms/Utils/BasicBlockUtils.cpp:1.10
--- llvm/lib/Transforms/Utils/BasicBlockUtils.cpp:1.9	Tue Nov 11 16:41:34 2003
+++ llvm/lib/Transforms/Utils/BasicBlockUtils.cpp	Fri Jan  9 00:12:10 2004
@@ -18,14 +18,13 @@
 #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 @@
 // 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 @@
 // 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 @@
 // 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 @@
     ReplaceInstWithInst(TI, NewTI);
 }
 
-} // End llvm namespace


Index: llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
diff -u llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.17 llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.18
--- llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.17	Fri Nov 21 10:52:03 2003
+++ llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp	Fri Jan  9 00:12:10 2004
@@ -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 @@
 }
 
 // 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 @@
 // 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 @@
 // 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 @@
   }
   return true;
 }
-
-} // End llvm namespace


Index: llvm/lib/Transforms/Utils/CloneFunction.cpp
diff -u llvm/lib/Transforms/Utils/CloneFunction.cpp:1.18 llvm/lib/Transforms/Utils/CloneFunction.cpp:1.19
--- llvm/lib/Transforms/Utils/CloneFunction.cpp:1.18	Tue Nov 11 16:41:34 2003
+++ llvm/lib/Transforms/Utils/CloneFunction.cpp	Fri Jan  9 00:12:12 2004
@@ -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 @@
 }
 
 // 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 @@
 // 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 @@
 /// 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 @@
   return NewF;                    
 }
 
-} // End llvm namespace


Index: llvm/lib/Transforms/Utils/CloneModule.cpp
diff -u llvm/lib/Transforms/Utils/CloneModule.cpp:1.8 llvm/lib/Transforms/Utils/CloneModule.cpp:1.9
--- llvm/lib/Transforms/Utils/CloneModule.cpp:1.8	Tue Nov 11 16:41:34 2003
+++ llvm/lib/Transforms/Utils/CloneModule.cpp	Fri Jan  9 00:12:15 2004
@@ -18,15 +18,14 @@
 #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 @@
 
   return New;
 }
-
-} // End llvm namespace


Index: llvm/lib/Transforms/Utils/CloneTrace.cpp
diff -u llvm/lib/Transforms/Utils/CloneTrace.cpp:1.4 llvm/lib/Transforms/Utils/CloneTrace.cpp:1.5
--- llvm/lib/Transforms/Utils/CloneTrace.cpp:1.4	Tue Nov 11 16:41:34 2003
+++ llvm/lib/Transforms/Utils/CloneTrace.cpp	Fri Jan  9 00:12:15 2004
@@ -18,13 +18,11 @@
 #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 @@
   //return new vector of basic blocks
   return clonedTrace;
 }
-
-} // End llvm namespace


Index: llvm/lib/Transforms/Utils/DemoteRegToStack.cpp
diff -u llvm/lib/Transforms/Utils/DemoteRegToStack.cpp:1.7 llvm/lib/Transforms/Utils/DemoteRegToStack.cpp:1.8
--- llvm/lib/Transforms/Utils/DemoteRegToStack.cpp:1.7	Tue Nov 11 16:41:34 2003
+++ llvm/lib/Transforms/Utils/DemoteRegToStack.cpp	Fri Jan  9 00:12:19 2004
@@ -21,16 +21,15 @@
 #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 @@
 //
 // 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 @@
 
   return XSlot;
 }
-
-} // End llvm namespace


Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.17 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.18
--- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.17	Thu Nov 20 12:25:23 2003
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp	Fri Jan  9 00:12:20 2004
@@ -23,11 +23,10 @@
 #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 @@
 // 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 @@
   SimplifyCFG(AfterCallBB);
   return true;
 }
-
-} // End llvm namespace


Index: llvm/lib/Transforms/Utils/Linker.cpp
diff -u llvm/lib/Transforms/Utils/Linker.cpp:1.64 llvm/lib/Transforms/Utils/Linker.cpp:1.65
--- llvm/lib/Transforms/Utils/Linker.cpp:1.64	Thu Nov 20 12:23:14 2003
+++ llvm/lib/Transforms/Utils/Linker.cpp	Fri Jan  9 00:12:24 2004
@@ -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 @@
 // 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 @@
   return false;
 }
 
-} // End llvm namespace


Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff -u llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.57 llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.58
--- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.57	Tue Nov 11 16:41:34 2003
+++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp	Fri Jan  9 00:12:25 2004
@@ -24,13 +24,12 @@
 #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 @@
 /// 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: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.18 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.19
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.18	Tue Nov 11 16:41:34 2003
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp	Fri Jan  9 00:12:25 2004
@@ -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 @@
 //
 // 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 @@
   
   return Changed;
 }
-
-} // End llvm namespace


Index: llvm/lib/Transforms/Utils/ValueMapper.cpp
diff -u llvm/lib/Transforms/Utils/ValueMapper.cpp:1.8 llvm/lib/Transforms/Utils/ValueMapper.cpp:1.9
--- llvm/lib/Transforms/Utils/ValueMapper.cpp:1.8	Tue Nov 11 16:41:34 2003
+++ llvm/lib/Transforms/Utils/ValueMapper.cpp	Fri Jan  9 00:12:25 2004
@@ -15,10 +15,9 @@
 #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 @@
   assert(0 && "Unknown value type: why didn't it get resolved?!");
   return 0;
 }
-
-} // End llvm namespace


Index: llvm/lib/Transforms/Utils/ValueMapper.h
diff -u llvm/lib/Transforms/Utils/ValueMapper.h:1.3 llvm/lib/Transforms/Utils/ValueMapper.h:1.4
--- llvm/lib/Transforms/Utils/ValueMapper.h:1.3	Tue Nov 11 16:41:34 2003
+++ llvm/lib/Transforms/Utils/ValueMapper.h	Fri Jan  9 00:12:26 2004
@@ -18,11 +18,8 @@
 #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





More information about the llvm-commits mailing list