diff options
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r-- | lib/Transforms/IPO/ArgumentPromotion.cpp | 16 | ||||
-rw-r--r-- | lib/Transforms/IPO/ConstantMerge.cpp | 16 | ||||
-rw-r--r-- | lib/Transforms/IPO/DeadArgumentElimination.cpp | 22 | ||||
-rw-r--r-- | lib/Transforms/IPO/DeadTypeElimination.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/IPO/ExtractFunction.cpp | 30 | ||||
-rw-r--r-- | lib/Transforms/IPO/FunctionResolution.cpp | 20 | ||||
-rw-r--r-- | lib/Transforms/IPO/GlobalDCE.cpp | 10 | ||||
-rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 46 | ||||
-rw-r--r-- | lib/Transforms/IPO/IPConstantPropagation.cpp | 10 | ||||
-rw-r--r-- | lib/Transforms/IPO/InlineSimple.cpp | 6 | ||||
-rw-r--r-- | lib/Transforms/IPO/Inliner.cpp | 20 | ||||
-rw-r--r-- | lib/Transforms/IPO/Inliner.h | 4 | ||||
-rw-r--r-- | lib/Transforms/IPO/Internalize.cpp | 10 | ||||
-rw-r--r-- | lib/Transforms/IPO/LoopExtractor.cpp | 22 | ||||
-rw-r--r-- | lib/Transforms/IPO/LowerSetJmp.cpp | 10 | ||||
-rw-r--r-- | lib/Transforms/IPO/PruneEH.cpp | 16 | ||||
-rw-r--r-- | lib/Transforms/IPO/RaiseAllocations.cpp | 18 | ||||
-rw-r--r-- | lib/Transforms/IPO/StripSymbols.cpp | 10 |
18 files changed, 145 insertions, 145 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index 87a8f02601..028fda9aeb 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -1,10 +1,10 @@ //===-- ArgumentPromotion.cpp - Promote by-reference arguments ------------===// -// +// // 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 pass promotes "by reference" arguments to be "by value" arguments. In @@ -67,7 +67,7 @@ namespace { virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC); private: bool PromoteArguments(CallGraphNode *CGN); - bool isSafeToPromoteArgument(Argument *Arg) const; + bool isSafeToPromoteArgument(Argument *Arg) const; Function *DoPromotion(Function *F, std::vector<Argument*> &ArgsToPromote); }; @@ -89,7 +89,7 @@ bool ArgPromotion::runOnSCC(const std::vector<CallGraphNode *> &SCC) { LocalChange |= PromoteArguments(SCC[i]); Changed |= LocalChange; // Remember that we changed something. } while (LocalChange); - + return Changed; } @@ -306,7 +306,7 @@ namespace { unsigned idx = 0; for (; idx < LHS.size() && idx < RHS.size(); ++idx) { if (LHS[idx] != RHS[idx]) { - return cast<ConstantInt>(LHS[idx])->getRawValue() < + return cast<ConstantInt>(LHS[idx])->getRawValue() < cast<ConstantInt>(RHS[idx])->getRawValue(); } } @@ -325,7 +325,7 @@ namespace { Function *ArgPromotion::DoPromotion(Function *F, std::vector<Argument*> &Args2Prom) { std::set<Argument*> ArgsToPromote(Args2Prom.begin(), Args2Prom.end()); - + // Start by computing a new prototype for the function, which is the same as // the old function, but has modified arguments. const FunctionType *FTy = F->getFunctionType(); @@ -391,7 +391,7 @@ Function *ArgPromotion::DoPromotion(Function *F, Params.push_back(Type::IntTy); } FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg()); - + // Create the new function body and insert it into the module... Function *NF = new Function(NFTy, F->getLinkage(), F->getName()); F->getParent()->getFunctionList().insert(F, NF); @@ -456,7 +456,7 @@ Function *ArgPromotion::DoPromotion(Function *F, Call->setName(""); New->setName(Name); } - + // Finally, remove the old call from the program, reducing the use-count of // F. Call->getParent()->getInstList().erase(Call); diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index 0140228b63..b6026f2736 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -1,10 +1,10 @@ //===- ConstantMerge.cpp - Merge duplicate global constants ---------------===// -// +// // 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 interface to a pass that merges duplicate global @@ -60,10 +60,10 @@ bool ConstantMerge::runOnModule(Module &M) { // Only process constants with initializers if (GV->isConstant() && GV->hasInitializer()) { Constant *Init = GV->getInitializer(); - + // Check to see if the initializer is already known... std::map<Constant*, GlobalVariable*>::iterator I = CMap.find(Init); - + if (I == CMap.end()) { // Nope, add it to the map CMap.insert(I, std::make_pair(Init, GV)); } else if (GV->hasInternalLinkage()) { // Yup, this is a duplicate! @@ -75,22 +75,22 @@ bool ConstantMerge::runOnModule(Module &M) { I->second = GV; } } - + if (Replacements.empty()) return MadeChange; CMap.clear(); - + // Now that we have figured out which replacements must be made, do them all // now. This avoid invalidating the pointers in CMap, which are unneeded // now. for (unsigned i = 0, e = Replacements.size(); i != e; ++i) { // Eliminate any uses of the dead global... Replacements[i].first->replaceAllUsesWith(Replacements[i].second); - + // Delete the global value from the module... M.getGlobalList().erase(Replacements[i].first); } - + NumMerged += Replacements.size(); Replacements.clear(); } diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index e226dc3311..d1b548a1f8 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -1,10 +1,10 @@ //===-- DeadArgumentElimination.cpp - Eliminate dead arguments ------------===// -// +// // 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 pass deletes dead arguments from internal functions. Dead argument @@ -88,7 +88,7 @@ namespace { void MarkArgumentLive(Argument *Arg); void MarkRetValLive(Function *F); void MarkReturnInstArgumentLive(ReturnInst *RI); - + void RemoveDeadArgumentsFromFunction(Function *F); }; RegisterOpt<DAE> X("deadargelim", "Dead Argument Elimination"); @@ -168,7 +168,7 @@ void DAE::SurveyFunction(Function &F) { if (!F.hasInternalLinkage() && (!ShouldHackArguments() || F.getIntrinsicID())) FunctionIntrinsicallyLive = true; - else + else for (Value::use_iterator I = F.use_begin(), E = F.use_end(); I != E; ++I) { // If this use is anything other than a call site, the function is alive. CallSite CS = CallSite::get(*I); @@ -197,7 +197,7 @@ void DAE::SurveyFunction(Function &F) { RetValLiveness = Live; break; } - + // If the function is PASSED IN as an argument, its address has been taken for (CallSite::arg_iterator AI = CS.arg_begin(), E = CS.arg_end(); AI != E; ++AI) @@ -300,11 +300,11 @@ bool DAE::isMaybeLiveArgumentNowLive(Argument *Arg) { void DAE::MarkArgumentLive(Argument *Arg) { std::set<Argument*>::iterator It = MaybeLiveArguments.lower_bound(Arg); if (It == MaybeLiveArguments.end() || *It != Arg) return; - + DEBUG(std::cerr << " MaybeLive argument now live: " << Arg->getName()<<"\n"); MaybeLiveArguments.erase(It); LiveArguments.insert(Arg); - + // Loop over all of the call sites of the function, making any arguments // passed in to provide a value for this argument live as necessary. // @@ -440,7 +440,7 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) { New->setName(Name); } } - + // Finally, remove the old call from the program, reducing the use-count of // F. Call->getParent()->getInstList().erase(Call); @@ -499,7 +499,7 @@ bool DAE::runOnModule(Module &M) { while (!InstructionsToInspect.empty()) { Instruction *I = InstructionsToInspect.back(); InstructionsToInspect.pop_back(); - + if (ReturnInst *RI = dyn_cast<ReturnInst>(I)) { // For return instructions, we just have to check to see if the return // value for the current function is known now to be alive. If so, any @@ -513,7 +513,7 @@ bool DAE::runOnModule(Module &M) { assert(CS.getInstruction() && "Unknown instruction for the I2I list!"); Function *Callee = CS.getCalledFunction(); - + // If we found a call or invoke instruction on this list, that means that // an argument of the function is a call instruction. If the argument is // live, then the return value of the called instruction is now live. @@ -556,7 +556,7 @@ bool DAE::runOnModule(Module &M) { if (MaybeLiveArguments.empty() && DeadArguments.empty() && MaybeLiveRetVal.empty() && DeadRetVal.empty()) return false; - + // Otherwise, compact into one set, and start eliminating the arguments from // the functions. DeadArguments.insert(MaybeLiveArguments.begin(), MaybeLiveArguments.end()); diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index b3a439e148..005d6bd600 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -1,10 +1,10 @@ //===- DeadTypeElimination.cpp - Eliminate unused types for symbol table --===// -// +// // 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 pass is used to cleanup the output of GCC. It eliminate names for types diff --git a/lib/Transforms/IPO/ExtractFunction.cpp b/lib/Transforms/IPO/ExtractFunction.cpp index 2d291b7a88..4cce79be61 100644 --- a/lib/Transforms/IPO/ExtractFunction.cpp +++ b/lib/Transforms/IPO/ExtractFunction.cpp @@ -1,10 +1,10 @@ //===-- ExtractFunction.cpp - Function extraction pass --------------------===// -// +// // 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 pass extracts @@ -25,7 +25,7 @@ namespace { /// specified function. Otherwise, it deletes as much of the module as /// possible, except for the function specified. /// - FunctionExtractorPass(Function *F = 0, bool deleteFn = true) + FunctionExtractorPass(Function *F = 0, bool deleteFn = true) : Named(F), deleteFunc(deleteFn) {} bool runOnModule(Module &M) { @@ -36,7 +36,7 @@ namespace { if (deleteFunc) return deleteFunction(); - else + else return isolateFunction(M); } @@ -57,31 +57,31 @@ namespace { I->setInitializer(0); // Make all variables external I->setLinkage(GlobalValue::ExternalLinkage); } - + // All of the functions may be used by global variables or the named // function. Loop through them and create a new, external functions that // can be "used", instead of ones with bodies. std::vector<Function*> NewFunctions; - + Function *Last = --M.end(); // Figure out where the last real fn is. - + for (Module::iterator I = M.begin(); ; ++I) { if (&*I != Named) { Function *New = new Function(I->getFunctionType(), GlobalValue::ExternalLinkage, I->getName()); I->setName(""); // Remove Old name - + // If it's not the named function, delete the body of the function I->dropAllReferences(); - + M.getFunctionList().push_back(New); NewFunctions.push_back(New); } - + if (&*I == Last) break; // Stop after processing the last function } - + // Now that we have replacements all set up, loop through the module, // deleting the old functions, replacing them with the newly created // functions. @@ -92,19 +92,19 @@ namespace { if (&*I != Named) { // Make everything that uses the old function use the new dummy fn I->replaceAllUsesWith(NewFunctions[FuncNum++]); - + Function *Old = I; ++I; // Move the iterator to the new function - + // Delete the old function! M.getFunctionList().erase(Old); - + } else { ++I; // Skip the function we are extracting } } while (&*I != NewFunctions[0]); } - + return true; } }; diff --git a/lib/Transforms/IPO/FunctionResolution.cpp b/lib/Transforms/IPO/FunctionResolution.cpp index dba44a0dc1..8b5019a0af 100644 --- a/lib/Transforms/IPO/FunctionResolution.cpp +++ b/lib/Transforms/IPO/FunctionResolution.cpp @@ -1,10 +1,10 @@ //===- FunctionResolution.cpp - Resolve declarations to implementations ---===// -// +// // 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. -// +// //===----------------------------------------------------------------------===// // // Loop over the functions that are in the module and look for functions that @@ -57,7 +57,7 @@ static bool ResolveFunctions(Module &M, std::vector<GlobalValue*> &Globals, Function *Old = cast<Function>(Globals[i]); const FunctionType *OldMT = Old->getFunctionType(); const FunctionType *ConcreteMT = Concrete->getFunctionType(); - + if (OldMT->getNumParams() > ConcreteMT->getNumParams() && !ConcreteMT->isVarArg()) if (!Old->use_empty()) { @@ -69,7 +69,7 @@ static bool ResolveFunctions(Module &M, std::vector<GlobalValue*> &Globals, WriteAsOperand(std::cerr, Concrete); std::cerr << "\n"; } - + // Check to make sure that if there are specified types, that they // match... // @@ -79,7 +79,7 @@ static bool ResolveFunctions(Module &M, std::vector<GlobalValue*> &Globals, if (!Old->use_empty() && !Concrete->use_empty()) for (unsigned i = 0; i < NumArguments; ++i) if (OldMT->getParamType(i) != ConcreteMT->getParamType(i)) - if (OldMT->getParamType(i)->getTypeID() != + if (OldMT->getParamType(i)->getTypeID() != ConcreteMT->getParamType(i)->getTypeID()) { std::cerr << "WARNING: Function [" << Old->getName() << "]: Parameter types conflict for: '"; @@ -89,7 +89,7 @@ static bool ResolveFunctions(Module &M, std::vector<GlobalValue*> &Globals, std::cerr << "'\n"; return Changed; } - + // Attempt to convert all of the uses of the old function to the concrete // form of the function. If there is a use of the fn that we don't // understand here we punt to avoid making a bad transformation. @@ -174,11 +174,11 @@ static bool ProcessGlobalsWithSameName(Module &M, TargetData &TD, if (!F->isExternal()) { if (Concrete && !Concrete->isExternal()) return false; // Found two different functions types. Can't choose! - + Concrete = Globals[i]; } else if (Concrete) { if (Concrete->isExternal()) // If we have multiple external symbols... - if (F->getFunctionType()->getNumParams() > + if (F->getFunctionType()->getNumParams() > cast<Function>(Concrete)->getFunctionType()->getNumParams()) Concrete = F; // We are more concrete than "Concrete"! @@ -213,7 +213,7 @@ static bool ProcessGlobalsWithSameName(Module &M, TargetData &TD, else if (!Globals[i]->hasInternalLinkage()) NumInstancesWithExternalLinkage++; } - + if (!HasExternal && NumInstancesWithExternalLinkage <= 1) return false; // Nothing to do? Must have multiple internal definitions. @@ -231,7 +231,7 @@ static bool ProcessGlobalsWithSameName(Module &M, TargetData &TD, OtherF->getFunctionType()->isVarArg() && OtherF->getFunctionType()->getNumParams() == 0) DontPrintWarning = true; - + // Otherwise, if the non-concrete global is a global array variable with a // size of 0, and the concrete global is an array with a real size, don't // warn. This occurs due to declaring 'extern int A[];'. diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index b7fa5dc7b9..072cef2eb5 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -1,10 +1,10 @@ //===-- GlobalDCE.cpp - DCE unreachable internal functions ----------------===// -// +// // 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 transform is designed to eliminate unreachable internal globals from the @@ -111,7 +111,7 @@ bool GlobalDCE::runOnModule(Module &M) { NumVariables += DeadGlobalVars.size(); Changed = true; } - + // Make sure that all memory is released AliveGlobals.clear(); return Changed; @@ -148,7 +148,7 @@ void GlobalDCE::GlobalIsNeeded(GlobalValue *G) { if (GlobalValue *GV = dyn_cast<GlobalValue>(*U)) GlobalIsNeeded(GV); else if (Constant *C = dyn_cast<Constant>(*U)) - MarkUsedGlobalsAsNeeded(C); + MarkUsedGlobalsAsNeeded(C); } } @@ -174,7 +174,7 @@ bool GlobalDCE::RemoveUnusedGlobalValue(GlobalValue &GV) { GV.removeDeadConstantUsers(); return GV.use_empty(); } - + // SafeToDestroyConstant - It is safe to destroy a constant iff it is only used // by constants itself. Note that constants cannot be cyclic, so this test is // pretty easy to implement recursively. diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 7b6f649a0a..e5bc5b8616 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -1,10 +1,10 @@ //===- GlobalOpt.cpp - Optimize Global Variables --------------------------===// -// +// // 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 pass transforms simple global variables that never have their address @@ -47,7 +47,7 @@ namespace { virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<TargetData>(); } - + bool runOnModule(Module &M); private: @@ -201,7 +201,7 @@ static bool AnalyzeGlobal(Value *V, GlobalStatus &GS, // If the first two indices are constants, this can be SRA'd. if (isa<GlobalVariable>(I->getOperand(0))) { if (I->getNumOperands() < 3 || !isa<Constant>(I->getOperand(1)) || - !cast<Constant>(I->getOperand(1))->isNullValue() || + !cast<Constant>(I->getOperand(1))->isNullValue() || !isa<ConstantInt>(I->getOperand(2))) GS.isNotSuitableForSRA = true; } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(I->getOperand(0))){ @@ -304,7 +304,7 @@ static bool CleanupConstantGlobalUsers(Value *V, Constant *Init) { bool Changed = false; for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;) { User *U = *UI++; - + if (LoadInst *LI = dyn_cast<LoadInst>(U)) { if (Init) { // Replace the load with the initializer. @@ -367,7 +367,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV) { assert(GV->hasInternalLinkage() && !GV->isConstant()); Constant *Init = GV->getInitializer(); const Type *Ty = Init->getType(); - + std::vector<GlobalVariable*> NewGlobals; Module::GlobalListType &Globals = GV->getParent()->getGlobalList(); @@ -422,7 +422,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV) { assert(((isa<ConstantExpr>(GEP) && cast<ConstantExpr>(GEP)->getOpcode()==Instruction::GetElementPtr)|| isa<GetElementPtrInst>(GEP)) && "NonGEP CE's are not SRAable!"); - + // Ignore the 1th operand, which has to be zero or else the program is quite // broken (undefined). Get the 2nd operand, which is the structure or array // index. @@ -499,7 +499,7 @@ static bool AllUsesOfValueWillTrapIfNull(Value *V) { if (!AllUsesOfValueWillTrapIfNull(CI)) return false; } else if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(*UI)) { if (!AllUsesOfValueWillTrapIfNull(GEPI)) return false; - } else if (isa<SetCondInst>(*UI) && + } else if (isa<SetCondInst>(*UI) && isa<ConstantPointerNull>(UI->getOperand(1))) { // Ignore setcc X, null } else { @@ -681,7 +681,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, MI->eraseFromParent(); MI = NewMI; } - + // Create the new global variable. The contents of the malloc'd memory is // undefined, so initialize with an undef value. Constant *Init = UndefValue::get(MI->getAllocatedType()); @@ -689,7 +689,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, GlobalValue::InternalLinkage, Init, GV->getName()+".body"); GV->getParent()->getGlobalList().insert(GV, NewGV); - + // Anything that used the malloc now uses the global directly. MI->replaceAllUsesWith(NewGV); @@ -699,8 +699,8 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, // If there is a comparison against null, we will insert a global bool to // keep track of whether the global was initialized yet or not. - GlobalVariable *InitBool = - new GlobalVariable(Type::BoolTy, false, GlobalValue::InternalLinkage, + GlobalVariable *InitBool = + new GlobalVariable(Type::BoolTy, false, GlobalValue::InternalLinkage, ConstantBool::False, GV->getName()+".init"); bool InitBoolUsed = false; @@ -817,7 +817,7 @@ static bool OptimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal, if (Constant *SOVC = dyn_cast<Constant>(StoredOnceVal)) { if (GV->getInitializer()->getType() != SOVC->getType()) SOVC = ConstantExpr::getCast(SOVC, GV->getInitializer()->getType()); - + // Optimize away any trapping uses of the loaded value. if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC)) return true; @@ -846,7 +846,7 @@ static bool OptimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal, } /// ShrinkGlobalToBoolean - At this point, we have learned that the only two -/// values ever stored into GV are its initializer and OtherVal. +/// values ever stored into GV are its initializer and OtherVal. static void ShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) { // Create the new global, initializing it to false. GlobalVariable *NewGV = new GlobalVariable(Type::BoolTy, false, @@ -895,13 +895,13 @@ static void ShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) { } else if (!UI->use_empty()) { // Change the load into a load of bool then a select. LoadInst *LI = cast<LoadInst>(UI); - + std::string Name = LI->getName(); LI->setName(""); LoadInst *NLI = new LoadInst(NewGV, Name+".b", LI); Value *NSI; if (IsOneZero) NSI = new CastInst(NLI, LI->getType(), Name, LI); - else + else NSI = new SelectInst(NLI, OtherVal, InitVal, Name, LI); LI->replaceAllUsesWith(NSI); } @@ -947,7 +947,7 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, AllocaInst* Alloca = new AllocaInst(ElemTy, NULL, GV->getName(), FirstI); if (!isa<UndefValue>(GV->getInitializer())) new StoreInst(GV->getInitializer(), Alloca, FirstI); - + GV->replaceAllUsesWith(Alloca); GV->eraseFromParent(); ++NumLocalized; @@ -969,14 +969,14 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, Changed = true; } return Changed; - + } else if (GS.StoredType <= GlobalStatus::isInitializerStored) { DEBUG(std::cerr << "MARKING CONSTANT: " << *GV); GV->setConstant(true); - + // Clean up any obviously simplifiable users now. CleanupConstantGlobalUsers(GV, GV->getInitializer()); - + // If the global is dead now, just nuke it. if (GV->use_empty()) { DEBUG(std::cerr << " *** Marking constant allowed us to simplify " @@ -984,7 +984,7 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, GV->eraseFromParent(); ++NumDeleted; } - + ++NumMarked; return true; } else if (!GS.isNotSuitableForSRA && @@ -1002,10 +1002,10 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, if (isa<UndefValue>(GV->getInitializer())) { // Change the initial value here. GV->setInitializer(SOVConstant); - + // Clean up any obviously simplifiable users now. CleanupConstantGlobalUsers(GV, GV->getInitializer()); - + if (GV->use_empty()) { DEBUG(std::cerr << " *** Substituting initializer allowed us to " "simplify all users and delete global!\n"); diff --git a/lib/Transforms/IPO/IPConstantPropagation.cpp b/lib/Transforms/IPO/IPConstantPropagation.cpp index 16839edff7..02395b5548 100644 --- a/lib/Transforms/IPO/IPConstantPropagation.cpp +++ b/lib/Transforms/IPO/IPConstantPropagation.cpp @@ -1,10 +1,10 @@ //===-- IPConstantPropagation.cpp - Propagate constants through calls -----===// -// +// // 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 pass implements an _extremely_ simple interprocedural constant @@ -81,10 +81,10 @@ bool IPCP::PropagateConstantsIntoArguments(Function &F) { return false; // Used by a non-instruction, do not transform else { CallSite CS = CallSite::get(cast<Instruction>(*I)); - if (CS.getInstruction() == 0 || + if (CS.getInstruction() == 0 || CS.getCalledFunction() != &F) return false; // Not a direct call site? - + // Check out all of the potentially constant arguments CallSite::arg_iterator AI = CS.arg_begin(); Function::arg_iterator Arg = F.arg_begin(); @@ -163,7 +163,7 @@ bool IPCP::PropagateConstantReturn(Function &F) { ReplacedAllUsers = false; else { CallSite CS = CallSite::get(cast<Instruction>(*I)); - if (CS.getInstruction() == 0 || + if (CS.getInstruction() == 0 || CS.getCalledFunction() != &F) { ReplacedAllUsers = false; } else { diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 4355c6c4a1..4bbefa3aac 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -1,10 +1,10 @@ //===- InlineSimple.cpp - Code to perform simple function inlining --------===// -// +// // 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 bottom-up inlining of functions into callees. @@ -101,7 +101,7 @@ static unsigned CountCodeReductionForConstant(Value *V) { if (AllOperandsConstant) { // We will get to remove this instruction... Reduction += 7; - + // And any other instructions that use it which become constants // themselves. Reduction += CountCodeReductionForConstant(&Inst); diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index 9c8d7aa910..36955e1f4d 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -1,10 +1,10 @@ //===- Inliner.cpp - Code common to all inliners --------------------------===// -// +// // 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 mechanics required to implement inlining without @@ -53,18 +53,18 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG, for (CallGraphNode::iterator I = CalleeNode->begin(), E = CalleeNode->end(); I != E; ++I) CallerNode->addCalledFunction(*I); - + // If we inlined the last possible call site to the function, delete the // function body now. if (Callee->use_empty() && Callee->hasInternalLinkage() && !SCCFunctions.count(Callee)) { DEBUG(std::cerr << " -> Deleting dead function: " << Callee->getName() << "\n"); - + // Remove any call graph edges from the callee to its callees. while (CalleeNode->begin() != CalleeNode->end()) CalleeNode->removeCallEdgeTo(*(CalleeNode->end()-1)); - + // Removing the node for callee from the call graph and delete it. delete CG.removeFunctionFromModule(CalleeNode); ++NumDeleted; @@ -99,7 +99,7 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) { } DEBUG(std::cerr << ": " << CallSites.size() << " call sites.\n"); - + // Now that we have all of the call sites, move the ones to functions in the // current SCC to the end of the list. unsigned FirstCallInSCC = CallSites.size(); @@ -107,7 +107,7 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) { if (Function *F = CallSites[i].getCalledFunction()) if (SCCFunctions.count(F)) std::swap(CallSites[i--], CallSites[--FirstCallInSCC]); - + // Now that we have all of the call sites, loop over them and inline them if // it looks profitable to do so. bool Changed = false; @@ -137,7 +137,7 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) { } else { DEBUG(std::cerr << " Inlining: cost=" << InlineCost << ", Call: " << *CS.getInstruction()); - + Function *Caller = CS.getInstruction()->getParent()->getParent(); // Attempt to inline the function... @@ -178,12 +178,12 @@ bool Inliner::doFinalization(CallGraph &CG) { // Remove any call graph edges from the function to its callees. while (CGN->begin() != CGN->end()) CGN->removeCallEdgeTo(*(CGN->end()-1)); - + // Remove any edges from the external node to the function's call graph // node. These edges might have been made irrelegant due to // optimization of the program. CG.getExternalCallingNode()->removeAnyCallEdgeTo(CGN); - + // Removing the node for callee from the call graph and delete it. FunctionsToRemove.insert(CGN); } diff --git a/lib/Transforms/IPO/Inliner.h b/lib/Transforms/IPO/Inliner.h index f937be2a53..c4662c1c52 100644 --- a/lib/Transforms/IPO/Inliner.h +++ b/lib/Transforms/IPO/Inliner.h @@ -1,10 +1,10 @@ //===- InlineCommon.h - Code common to all inliners -------------*- 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 a simple policy-based bottom-up inliner. This file diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp index 5a254fa687..85a7abd101 100644 --- a/lib/Transforms/IPO/Internalize.cpp +++ b/lib/Transforms/IPO/Internalize.cpp @@ -1,10 +1,10 @@ //===-- Internalize.cpp - Mark functions internal -------------------------===// -// +// // 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 pass loops over all of the functions in the input module, looking for a @@ -38,7 +38,7 @@ namespace { APIList("internalize-public-api-list", cl::value_desc("list"), cl::desc("A list of symbol names to preserve"), cl::CommaSeparated); - + class InternalizePass : public ModulePass { std::set<std::string> ExternalNames; public: @@ -80,7 +80,7 @@ namespace { } bool Changed = false; - + // Found a main function, mark all functions not named main as internal. for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isExternal() && // Function must be defined here @@ -109,7 +109,7 @@ namespace { ++NumGlobals; DEBUG(std::cerr << "Internalizing gvar " << I->getName() << "\n"); } - + return Changed; } }; diff --git a/lib/Transforms/IPO/LoopExtractor.cpp b/lib/Transforms/IPO/LoopExtractor.cpp index 4fd2335c28..39d0fca94f 100644 --- a/lib/Transforms/IPO/LoopExtractor.cpp +++ b/lib/Transforms/IPO/LoopExtractor.cpp @@ -1,10 +1,10 @@ //===- LoopExtractor.cpp - Extract each loop into a new function ----------===// -// +// // 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. -// +// //===----------------------------------------------------------------------===// // // A pass wrapper around the ExtractLoop() scalar transformation to extract each @@ -27,7 +27,7 @@ using namespace llvm; namespace { Statistic<> NumExtracted("loop-extract", "Number of loops extracted"); - + // FIXME: This is not a function pass, but the PassManager doesn't allow // Module passes to require FunctionPasses, so we can't get loop info if we're // not a function pass. @@ -37,7 +37,7 @@ namespace { LoopExtractor(unsigned numLoops = ~0) : NumLoops(numLoops) {} virtual bool runOnFunction(Function &F); - + virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequiredID(BreakCriticalEdgesID); AU.addRequiredID(LoopSimplifyID); @@ -46,7 +46,7 @@ namespace { } }; - RegisterOpt<LoopExtractor> + RegisterOpt<LoopExtractor> X("loop-extract", "Extract loops into new functions"); /// SingleLoopExtractor - For bugpoint. @@ -54,9 +54,9 @@ namespace { SingleLoopExtractor() : LoopExtractor(1) {} }; - RegisterOpt<SingleLoopExtractor> + RegisterOpt<SingleLoopExtractor> Y("loop-extract-single", "Extract at most one loop into a new function"); -} // End anonymous namespace +} // End anonymous namespace // createLoopExtractorPass - This pass extracts all natural loops from the // program into a function if it can. @@ -87,11 +87,11 @@ bool LoopExtractor::runOnFunction(Function &F) { // than a minimal wrapper around the loop, extract the loop. Loop *TLL = *LI.begin(); bool ShouldExtractLoop = false; - + // Extract the loop if the entry block doesn't branch to the loop header. TerminatorInst *EntryTI = F.getEntryBlock().getTerminator(); if (!isa<BranchInst>(EntryTI) || - !cast<BranchInst>(EntryTI)->isUnconditional() || + !cast<BranchInst>(EntryTI)->isUnconditional() || EntryTI->getSuccessor(0) != TLL->getHeader()) ShouldExtractLoop = true; else { @@ -105,7 +105,7 @@ bool LoopExtractor::runOnFunction(Function &F) { break; } } - + if (ShouldExtractLoop) { if (NumLoops == 0) return Changed; --NumLoops; @@ -184,6 +184,6 @@ bool BlockExtractorPass::runOnModule(Module &M) { for (unsigned i = 0, e = BlocksToExtract.size(); i != e; ++i) ExtractBasicBlock(BlocksToExtract[i]); - + return !BlocksToExtract.empty(); } diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index 38828d9dcc..266729d6ca 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -1,10 +1,10 @@ //===- LowerSetJmp.cpp - Code pertaining to lowering set/long jumps -------===// -// +// // 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 lowering of setjmp and longjmp to use the @@ -204,7 +204,7 @@ bool LowerSetJmp::doInitialization(Module& M) // void __llvm_sjljeh_init_setjmpmap(void**) InitSJMap = M.getOrInsertFunction("__llvm_sjljeh_init_setjmpmap", - Type::VoidTy, SBPPTy, 0); + Type::VoidTy, SBPPTy, 0); // void __llvm_sjljeh_destroy_setjmpmap(void**) DestroySJMap = M.getOrInsertFunction("__llvm_sjljeh_destroy_setjmpmap", Type::VoidTy, SBPPTy, 0); @@ -386,7 +386,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst) // instructions after the call. for (BasicBlock::iterator I = ++BasicBlock::iterator(Inst), E = ABlock->end(); I != E; ++I) - InstrsAfterCall.insert(I); + InstrsAfterCall.insert(I); for (BasicBlock::iterator II = ABlock->begin(); II != BasicBlock::iterator(Inst); ++II) @@ -460,7 +460,7 @@ void LowerSetJmp::visitCallInst(CallInst& CI) std::vector<Value*> Params(CI.op_begin() + 1, CI.op_end()); InvokeInst* II = new InvokeInst(CI.getCalledValue(), NewBB, PrelimBBMap[Func], - Params, CI.getName(), Term); + Params, CI.getName(), Term); // Replace the old call inst with the invoke inst and remove the call. CI.replaceAllUsesWith(II); diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp index 9601d143f7..381722e48c 100644 --- a/lib/Transforms/IPO/PruneEH.cpp +++ b/lib/Transforms/IPO/PruneEH.cpp @@ -1,10 +1,10 @@ //===- PruneEH.cpp - Pass which deletes unused exception handlers ---------===// -// +// // 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 a simple interprocedural pass which walks the @@ -77,7 +77,7 @@ bool PruneEH::runOnSCC(const std::vector<CallGraphNode *> &SCC) { SCCMightThrow = true; break; } - + } else { // Indirect call, it might throw. SCCMightThrow = true; @@ -109,24 +109,24 @@ bool PruneEH::runOnSCC(const std::vector<CallGraphNode *> &SCC) { std::vector<Value*>(II->op_begin()+3, II->op_end()), Name, II); - + // Anything that used the value produced by the invoke instruction // now uses the value produced by the call instruction. II->replaceAllUsesWith(Call); II->getUnwindDest()->removePredecessor(II->getParent()); - + // Insert a branch to the normal destination right before the // invoke. new BranchInst(II->getNormalDest(), II); - + // Finally, delete the invoke instruction! I->getInstList().pop_back(); - + ++NumRemoved; MadeChange = true; } } - return MadeChange; + return MadeChange; } diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp index 8a35bc39e6..2b487d009d 100644 --- a/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/lib/Transforms/IPO/RaiseAllocations.cpp @@ -1,10 +1,10 @@ //===- RaiseAllocations.cpp - Convert %malloc & %free calls to insts ------===// -// +// // 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 RaiseAllocations pass which convert malloc and free @@ -33,17 +33,17 @@ namespace { Function *FreeFunc; // Initialized by doPassInitializationVirt public: RaiseAllocations() : MallocFunc(0), FreeFunc(0) {} - + // doPassInitialization - For the raise allocations pass, this finds a // declaration for malloc and free if they exist. // void doInitialization(Module &M); - + // run - This method does the actual work of converting instructions over. // bool runOnModule(Module &M); }; - + RegisterOpt<RaiseAllocations> X("raiseallocs", "Raise allocations from calls to instructions"); } // end anonymous namespace @@ -134,14 +134,14 @@ bool RaiseAllocations::runOnModule(Module &M) { (CS.getCalledFunction() == MallocFunc || std::find(EqPointers.begin(), EqPointers.end(), CS.getCalledValue()) != EqPointers.end())) { - + Value *Source = *CS.arg_begin(); - + // If no prototype was provided for malloc, we may need to cast the // source size. if (Source->getType() != Type::UIntTy) Source = new CastInst(Source, Type::UIntTy, "MallocAmtCast", I); - + std::string Name(I->getName()); I->setName(""); MallocInst *MI = new MallocInst(Type::SByteTy, Source, Name, I); I->replaceAllUsesWith(MI); @@ -183,7 +183,7 @@ bool RaiseAllocations::runOnModule(Module &M) { (CS.getCalledFunction() == FreeFunc || std::find(EqPointers.begin(), EqPointers.end(), CS.getCalledValue()) != EqPointers.end())) { - + // If no prototype was provided for free, we may need to cast the // source pointer. This should be really uncommon, but it's necessary // just in case we are dealing with weird code like this: diff --git a/lib/Transforms/IPO/StripSymbols.cpp b/lib/Transforms/IPO/StripSymbols.cpp index 80fe394f61..e1f7ea97ee 100644 --- a/lib/Transforms/IPO/StripSymbols.cpp +++ b/lib/Transforms/IPO/StripSymbols.cpp @@ -1,10 +1,10 @@ //===- StripSymbols.cpp - Strip symbols and debug info from a module ------===// -// +// // 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 stripping symbols out of symbol tables. @@ -17,7 +17,7 @@ // // Notice that: // * This pass makes code much less readable, so it should only be used in -// situations where the 'strip' utility would be used (such as reducing +// situations where the 'strip' utility would be used (such as reducing // code size, and making it harder to reverse engineer code). // //===----------------------------------------------------------------------===// @@ -63,7 +63,7 @@ static void RemoveDeadConstant(Constant *C) { } else if (!isa<Function>(C)) C->destroyConstant(); - + // If the constant referenced anything, see if we can delete it as well. while (!Operands.empty()) { RemoveDeadConstant(Operands.back()); @@ -144,5 +144,5 @@ bool StripSymbols::runOnModule(Module &M) { RemoveDeadConstant(GV); } - return true; + return true; } |