Finegrainify namespacification

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10727 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-01-09 06:12:26 +00:00
parent 21949d9088
commit f7703df496
17 changed files with 57 additions and 103 deletions

View 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

View 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

View 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

View 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

View File

@ -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 @@ 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

View 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

View 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

View File

@ -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 @@ Module *CloneModule(const Module *M) {
return New;
}
} // End llvm namespace

View File

@ -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 @@ std::vector<BasicBlock *> CloneTrace(const std::vector<BasicBlock*> &origTrace)
//return new vector of basic blocks
return clonedTrace;
}
} // End llvm namespace

View File

@ -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 @@ 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

View File

@ -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 @@ 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

View 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

View File

@ -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 @@ 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

View 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

View File

@ -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 @@ 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

View File

@ -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

View 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