#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...
// 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)
return false;
}
-} // End llvm namespace
#include "llvm/Pass.h"
#include "llvm/Function.h"
-
-namespace llvm {
+using namespace llvm;
namespace {
// Hello - The first implementation, without getAnalysisUsage.
};
RegisterOpt<Hello2> Y("hello2", "Hello World Pass (with getAnalysisUsage implemented)");
}
-
-} // End llvm namespace
#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) {
return true;
}
-} // End llvm namespace
#include "Support/StringExtras.h"
#include <algorithm>
#include <sstream>
-
-namespace llvm {
+using namespace llvm;
static cl::opt<bool>
DisablePtrHashing("tracedisablehashdisable", cl::Hidden,
} // 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();
}
return true;
}
-
-} // End llvm namespace
#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);
// 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!");
// 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);
}
// 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!");
ReplaceInstWithInst(TI, NewTI);
}
-} // End llvm namespace
#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");
}
// 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.
// 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;
// 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);
}
return true;
}
-
-} // End llvm namespace
#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.
}
// 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);
// 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
/// 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
return NewF;
}
-} // End llvm namespace
#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());
return New;
}
-
-} // End llvm namespace
#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;
//return new vector of basic blocks
return clonedTrace;
}
-
-} // End llvm namespace
#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);
//
// 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!
return XSlot;
}
-
-} // End llvm namespace
#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
// 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!");
SimplifyCFG(AfterCallBB);
return true;
}
-
-} // End llvm namespace
#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...
// 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)
return false;
}
-} // End llvm namespace
#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.
/// 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
#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
//
// 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();
return Changed;
}
-
-} // End llvm namespace
#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?
assert(0 && "Unknown value type: why didn't it get resolved?!");
return 0;
}
-
-} // End llvm namespace
#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
#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...
// 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)
return false;
}
-} // End llvm namespace