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(); |