LLVM API Documentation
#include "llvm/Transforms/IPO.h"#include "llvm/ADT/DenseMap.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/ConstantFolding.h"#include "llvm/Analysis/MemoryBuiltins.h"#include "llvm/IR/CallingConv.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/DerivedTypes.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Module.h"#include "llvm/IR/Operator.h"#include "llvm/Pass.h"#include "llvm/Support/CallSite.h"#include "llvm/Support/Debug.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Support/GetElementPtrTypeIterator.h"#include "llvm/Support/MathExtras.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Target/TargetLibraryInfo.h"#include <algorithm>
Go to the source code of this file.
Defines | |
| #define | DEBUG_TYPE "globalopt" |
Functions | |
| STATISTIC (NumMarked,"Number of globals marked constant") | |
| STATISTIC (NumUnnamed,"Number of globals marked unnamed_addr") | |
| STATISTIC (NumSRA,"Number of aggregate globals broken into scalars") | |
| STATISTIC (NumHeapSRA,"Number of heap objects SRA'd") | |
| STATISTIC (NumSubstitute,"Number of globals with initializers stored into them") | |
| STATISTIC (NumDeleted,"Number of globals deleted") | |
| STATISTIC (NumFnDeleted,"Number of functions deleted") | |
| STATISTIC (NumGlobUses,"Number of global uses devirtualized") | |
| STATISTIC (NumLocalized,"Number of globals localized") | |
| STATISTIC (NumShrunkToBool,"Number of global vars shrunk to booleans") | |
| STATISTIC (NumFastCallFns,"Number of functions converted to fastcc") | |
| STATISTIC (NumCtorsEvaluated,"Number of static ctors evaluated") | |
| STATISTIC (NumNestRemoved,"Number of nest attributes removed") | |
| STATISTIC (NumAliasesResolved,"Number of global aliases resolved") | |
| STATISTIC (NumAliasesRemoved,"Number of global aliases eliminated") | |
| STATISTIC (NumCXXDtorsRemoved,"Number of global C++ destructors removed") | |
| INITIALIZE_PASS_BEGIN (GlobalOpt,"globalopt","Global Variable Optimizer", false, false) INITIALIZE_PASS_END(GlobalOpt | |
| static AtomicOrdering | StrongerOrdering (AtomicOrdering X, AtomicOrdering Y) |
| static bool | SafeToDestroyConstant (const Constant *C) |
| static bool | AnalyzeGlobal (const Value *V, GlobalStatus &GS, SmallPtrSet< const PHINode *, 16 > &PHIUsers) |
| static bool | isLeakCheckerRoot (GlobalVariable *GV) |
| static bool | IsSafeComputationToRemove (Value *V, const TargetLibraryInfo *TLI) |
| static bool | CleanupPointerRootUsers (GlobalVariable *GV, const TargetLibraryInfo *TLI) |
| static bool | CleanupConstantGlobalUsers (Value *V, Constant *Init, DataLayout *TD, TargetLibraryInfo *TLI) |
| static bool | isSafeSROAElementUse (Value *V) |
| static bool | IsUserOfGlobalSafeForSRA (User *U, GlobalValue *GV) |
| static bool | GlobalUsersSafeToSRA (GlobalValue *GV) |
| static GlobalVariable * | SRAGlobal (GlobalVariable *GV, const DataLayout &TD) |
| static bool | AllUsesOfValueWillTrapIfNull (const Value *V, SmallPtrSet< const PHINode *, 8 > &PHIs) |
| static bool | AllUsesOfLoadedValueWillTrapIfNull (const GlobalVariable *GV) |
| static bool | OptimizeAwayTrappingUsesOfValue (Value *V, Constant *NewV) |
| static bool | OptimizeAwayTrappingUsesOfLoads (GlobalVariable *GV, Constant *LV, DataLayout *TD, TargetLibraryInfo *TLI) |
| static void | ConstantPropUsersOf (Value *V, DataLayout *TD, TargetLibraryInfo *TLI) |
| static GlobalVariable * | OptimizeGlobalAddressOfMalloc (GlobalVariable *GV, CallInst *CI, Type *AllocTy, ConstantInt *NElements, DataLayout *TD, TargetLibraryInfo *TLI) |
| static bool | ValueIsOnlyUsedLocallyOrStoredToOneGlobal (const Instruction *V, const GlobalVariable *GV, SmallPtrSet< const PHINode *, 8 > &PHIs) |
| static void | ReplaceUsesOfMallocWithGlobal (Instruction *Alloc, GlobalVariable *GV) |
| static bool | LoadUsesSimpleEnoughForHeapSRA (const Value *V, SmallPtrSet< const PHINode *, 32 > &LoadUsingPHIs, SmallPtrSet< const PHINode *, 32 > &LoadUsingPHIsPerLoad) |
| static bool | AllGlobalLoadUsesSimpleEnoughForHeapSRA (const GlobalVariable *GV, Instruction *StoredVal) |
| static Value * | GetHeapSROAValue (Value *V, unsigned FieldNo, DenseMap< Value *, std::vector< Value * > > &InsertedScalarizedValues, std::vector< std::pair< PHINode *, unsigned > > &PHIsToRewrite) |
| static void | RewriteHeapSROALoadUser (Instruction *LoadUser, DenseMap< Value *, std::vector< Value * > > &InsertedScalarizedValues, std::vector< std::pair< PHINode *, unsigned > > &PHIsToRewrite) |
| static void | RewriteUsesOfLoadForHeapSRoA (LoadInst *Load, DenseMap< Value *, std::vector< Value * > > &InsertedScalarizedValues, std::vector< std::pair< PHINode *, unsigned > > &PHIsToRewrite) |
| static GlobalVariable * | PerformHeapAllocSRoA (GlobalVariable *GV, CallInst *CI, Value *NElems, DataLayout *TD, const TargetLibraryInfo *TLI) |
| static bool | TryToOptimizeStoreOfMallocToGlobal (GlobalVariable *GV, CallInst *CI, Type *AllocTy, AtomicOrdering Ordering, Module::global_iterator &GVI, DataLayout *TD, TargetLibraryInfo *TLI) |
| static bool | OptimizeOnceStoredGlobal (GlobalVariable *GV, Value *StoredOnceVal, AtomicOrdering Ordering, Module::global_iterator &GVI, DataLayout *TD, TargetLibraryInfo *TLI) |
| static bool | TryToShrinkGlobalToBoolean (GlobalVariable *GV, Constant *OtherVal) |
| static void | ChangeCalleesToFastCall (Function *F) |
| static AttributeSet | StripNest (LLVMContext &C, const AttributeSet &Attrs) |
| static void | RemoveNestAttribute (Function *F) |
| static std::vector< Function * > | ParseGlobalCtors (GlobalVariable *GV) |
| static GlobalVariable * | InstallGlobalCtors (GlobalVariable *GCL, const std::vector< Function * > &Ctors) |
| static bool | isSimpleEnoughValueToCommit (Constant *C, SmallPtrSet< Constant *, 8 > &SimpleConstants, const DataLayout *TD) |
| static bool | isSimpleEnoughValueToCommitHelper (Constant *C, SmallPtrSet< Constant *, 8 > &SimpleConstants, const DataLayout *TD) |
| static bool | isSimpleEnoughPointerToCommit (Constant *C) |
| static Constant * | EvaluateStoreInto (Constant *Init, Constant *Val, ConstantExpr *Addr, unsigned OpNo) |
| static void | CommitValueTo (Constant *Val, Constant *Addr) |
| static bool | EvaluateStaticConstructor (Function *F, const DataLayout *TD, const TargetLibraryInfo *TLI) |
| static GlobalVariable * | collectUsedGlobalVariables (const Module &M, const char *Name, SmallPtrSet< GlobalValue *, 8 > &Set) |
| Given "llvm.used" or "llvm.compiler_used" as a global name, collect the initializer elements of that global in Set and return the global itself. | |
| static int | compareNames (const void *A, const void *B) |
| static void | setUsedInitializer (GlobalVariable &V, SmallPtrSet< GlobalValue *, 8 > Init) |
| static bool | hasUseOtherThanLLVMUsed (GlobalAlias &GA, const LLVMUsed &U) |
| static bool | hasMoreThanOneUseOtherThanLLVMUsed (GlobalValue &V, const LLVMUsed &U) |
| static bool | mayHaveOtherReferences (GlobalAlias &GA, const LLVMUsed &U) |
| static bool | hasUsesToReplace (GlobalAlias &GA, LLVMUsed &U, bool &RenameTarget) |
| static Function * | FindCXAAtExit (Module &M, TargetLibraryInfo *TLI) |
| static bool | cxxDtorIsEmpty (const Function &Fn, SmallPtrSet< const Function *, 8 > &CalledFunctions) |
Variables | |
| globalopt | |
| Global Variable | Optimizer |
| Global Variable | false |
| #define DEBUG_TYPE "globalopt" |
Definition at line 16 of file GlobalOpt.cpp.
| static bool AllGlobalLoadUsesSimpleEnoughForHeapSRA | ( | const GlobalVariable * | GV, |
| Instruction * | StoredVal | ||
| ) | [static] |
AllGlobalLoadUsesSimpleEnoughForHeapSRA - If all users of values loaded from GV are simple enough to perform HeapSRA, return true.
Definition at line 1301 of file GlobalOpt.cpp.
References llvm::SmallPtrSet< PtrType, SmallSize >::begin(), llvm::SmallPtrSetImpl::clear(), llvm::SmallPtrSet< PtrType, SmallSize >::count(), llvm::SmallPtrSet< PtrType, SmallSize >::end(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), I, LI, LoadUsesSimpleEnoughForHeapSRA(), llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by TryToOptimizeStoreOfMallocToGlobal().
| static bool AllUsesOfLoadedValueWillTrapIfNull | ( | const GlobalVariable * | GV | ) | [static] |
AllUsesOfLoadedValueWillTrapIfNull - Return true if all uses of any loads from GV will trap if the loaded value is null. Note that this also permits comparisons of the loaded value against null, as a special case.
Definition at line 851 of file GlobalOpt.cpp.
References AllUsesOfValueWillTrapIfNull(), LI, llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by TryToOptimizeStoreOfMallocToGlobal().
| static bool AllUsesOfValueWillTrapIfNull | ( | const Value * | V, |
| SmallPtrSet< const PHINode *, 8 > & | PHIs | ||
| ) | [static] |
AllUsesOfValueWillTrapIfNull - Return true if all users of the specified value will trap if the value is dynamically null. PHIs keeps track of any phi nodes we've seen to avoid reprocessing them.
Definition at line 805 of file GlobalOpt.cpp.
References llvm::SmallPtrSet< PtrType, SmallSize >::insert(), llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by AllUsesOfLoadedValueWillTrapIfNull().
| static bool AnalyzeGlobal | ( | const Value * | V, |
| GlobalStatus & | GS, | ||
| SmallPtrSet< const PHINode *, 16 > & | PHIUsers | ||
| ) | [static] |
AnalyzeGlobal - Look at all uses of the global and fill in the GlobalStatus structure. If the global has its address taken, return true to indicate we can't do anything with it.
Definition at line 192 of file GlobalOpt.cpp.
References llvm::CallingConv::C, F(), I, if(), llvm::SmallPtrSet< PtrType, SmallSize >::insert(), LI, SafeToDestroyConstant(), StrongerOrdering(), llvm::Value::use_begin(), and llvm::Value::use_end().
| static void ChangeCalleesToFastCall | ( | Function * | F | ) | [static] |
ChangeCalleesToFastCall - Walk all of the direct calls of the specified function, changing them to FastCC.
Definition at line 2063 of file GlobalOpt.cpp.
References llvm::CallingConv::Fast, llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::setCallingConv(), llvm::Value::use_begin(), and llvm::Value::use_end().
| static bool CleanupConstantGlobalUsers | ( | Value * | V, |
| Constant * | Init, | ||
| DataLayout * | TD, | ||
| TargetLibraryInfo * | TLI | ||
| ) | [static] |
CleanupConstantGlobalUsers - We just marked GV constant. Loop over all users of the global, cleaning up the obvious ones. This is largely just a quick scan over the use list to clean up the easy and obvious cruft. This returns true if it made a change.
Definition at line 470 of file GlobalOpt.cpp.
References llvm::CallingConv::C, llvm::ConstantFoldInstruction(), llvm::ConstantFoldLoadThroughGEPConstantExpr(), llvm::Constant::getNullValue(), llvm::ConstantExpr::getOpcode(), LI, llvm::A64CC::MI, SafeToDestroyConstant(), llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by OptimizeAwayTrappingUsesOfLoads().
| static bool CleanupPointerRootUsers | ( | GlobalVariable * | GV, |
| const TargetLibraryInfo * | TLI | ||
| ) | [static] |
CleanupPointerRootUsers - This GV is a pointer root. Loop over all users of the global and clean up any that obviously don't assign the global a value that isn't dynamically allocated.
Definition at line 383 of file GlobalOpt.cpp.
References llvm::CallingConv::C, llvm::SmallVectorImpl< T >::clear(), llvm::RegState::Dead, llvm::dyn_cast(), llvm::Instruction::eraseFromParent(), llvm::User::getOperand(), I, llvm::isAllocationFn(), llvm::GlobalVariable::isConstant(), IsSafeComputationToRemove(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), SafeToDestroyConstant(), llvm::SmallVectorTemplateCommon< T >::size(), llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by OptimizeAwayTrappingUsesOfLoads().
| static GlobalVariable* collectUsedGlobalVariables | ( | const Module & | M, |
| const char * | Name, | ||
| SmallPtrSet< GlobalValue *, 8 > & | Set | ||
| ) | [static] |
Given "llvm.used" or "llvm.compiler_used" as a global name, collect the initializer elements of that global in Set and return the global itself.
Definition at line 3047 of file GlobalOpt.cpp.
References G, llvm::Module::getGlobalVariable(), llvm::GlobalVariable::getInitializer(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::GlobalVariable::hasInitializer(), I, llvm::SmallPtrSet< PtrType, SmallSize >::insert(), and llvm::Value::stripPointerCastsNoFollowAliases().
CommitValueTo - We have decided that Addr (which satisfies the predicate isSimpleEnoughPointerToCommit) should get Val as its value. Make it happen.
Definition at line 2447 of file GlobalOpt.cpp.
References EvaluateStoreInto(), llvm::User::getOperand(), llvm::GlobalVariable::hasInitializer(), and llvm::GlobalVariable::setInitializer().
Referenced by EvaluateStaticConstructor().
| static int compareNames | ( | const void * | A, |
| const void * | B | ||
| ) | [static] |
Definition at line 3062 of file GlobalOpt.cpp.
References llvm::ARM_PROC::A, and llvm::Value::getName().
Referenced by setUsedInitializer().
| static void ConstantPropUsersOf | ( | Value * | V, |
| DataLayout * | TD, | ||
| TargetLibraryInfo * | TLI | ||
| ) | [static] |
ConstantPropUsersOf - Walk the use list of V, constant folding all of the instructions that are foldable.
Definition at line 1002 of file GlobalOpt.cpp.
References llvm::ConstantFoldInstruction(), I, llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by OptimizeGlobalAddressOfMalloc().
| static bool cxxDtorIsEmpty | ( | const Function & | Fn, |
| SmallPtrSet< const Function *, 8 > & | CalledFunctions | ||
| ) | [static] |
cxxDtorIsEmpty - Returns whether the given function is an empty C++ destructor and can therefore be eliminated. Note that we assume that other optimization passes have already simplified the code so we only look for a function with a single basic block, where the only allowed instructions are 'ret', 'call' to an empty C++ dtor and other side-effect free instructions.
Definition at line 3284 of file GlobalOpt.cpp.
References llvm::BasicBlock::begin(), llvm::Function::begin(), llvm::BasicBlock::end(), llvm::Function::end(), llvm::Function::getEntryBlock(), I, llvm::SmallPtrSet< PtrType, SmallSize >::insert(), and llvm::GlobalValue::isDeclaration().
| static bool EvaluateStaticConstructor | ( | Function * | F, |
| const DataLayout * | TD, | ||
| const TargetLibraryInfo * | TLI | ||
| ) | [static] |
EvaluateStaticConstructor - Evaluate static constructors in the function, if we can. Return true if we can, false otherwise.
Definition at line 2978 of file GlobalOpt.cpp.
References CommitValueTo(), llvm::dbgs(), DEBUG, llvm::Eval(), Evaluator, llvm::Value::getName(), and I.
| static Constant* EvaluateStoreInto | ( | Constant * | Init, |
| Constant * | Val, | ||
| ConstantExpr * | Addr, | ||
| unsigned | OpNo | ||
| ) | [static] |
EvaluateStoreInto - Evaluate a piece of a constantexpr store into a global initializer. This returns 'Init' modified to reflect 'Val' stored into it. At this point, the GEP operands of Addr [0, OpNo) have been stepped into.
Definition at line 2399 of file GlobalOpt.cpp.
References llvm::ConstantArray::get(), llvm::ConstantStruct::get(), llvm::ConstantVector::get(), llvm::Constant::getAggregateElement(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::ConstantInt::getZExtValue(), llvm::Type::isArrayTy(), and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().
Referenced by CommitValueTo().
| static Function* FindCXAAtExit | ( | Module & | M, |
| TargetLibraryInfo * | TLI | ||
| ) | [static] |
Definition at line 3255 of file GlobalOpt.cpp.
References llvm::LibFunc::cxa_atexit, llvm::Module::getFunction(), llvm::Function::getFunctionType(), llvm::TargetLibraryInfo::getName(), llvm::FunctionType::getNumParams(), llvm::FunctionType::getParamType(), llvm::FunctionType::getReturnType(), llvm::TargetLibraryInfo::has(), llvm::Type::isIntegerTy(), and llvm::Type::isPointerTy().
| static Value* GetHeapSROAValue | ( | Value * | V, |
| unsigned | FieldNo, | ||
| DenseMap< Value *, std::vector< Value * > > & | InsertedScalarizedValues, | ||
| std::vector< std::pair< PHINode *, unsigned > > & | PHIsToRewrite | ||
| ) | [static] |
Definition at line 1350 of file GlobalOpt.cpp.
References llvm::PHINode::Create(), llvm::StructType::getElementType(), llvm::PointerType::getUnqual(), LI, llvm_unreachable, and llvm::A64DB::ST.
Referenced by PerformHeapAllocSRoA(), and RewriteHeapSROALoadUser().
| static bool GlobalUsersSafeToSRA | ( | GlobalValue * | GV | ) | [static] |
GlobalUsersSafeToSRA - Look at all uses of the global and decide whether it is safe for us to perform this transformation.
Definition at line 648 of file GlobalOpt.cpp.
References IsUserOfGlobalSafeForSRA(), llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by SRAGlobal().
| static bool hasMoreThanOneUseOtherThanLLVMUsed | ( | GlobalValue & | V, |
| const LLVMUsed & | U | ||
| ) | [static] |
Definition at line 3149 of file GlobalOpt.cpp.
References llvm::Value::hasNUsesOrMore(), and N.
Referenced by hasUsesToReplace().
| static bool hasUseOtherThanLLVMUsed | ( | GlobalAlias & | GA, |
| const LLVMUsed & | U | ||
| ) | [static] |
Definition at line 3133 of file GlobalOpt.cpp.
References llvm::Value::hasOneUse(), and llvm::Value::use_empty().
Referenced by hasUsesToReplace().
| static bool hasUsesToReplace | ( | GlobalAlias & | GA, |
| LLVMUsed & | U, | ||
| bool & | RenameTarget | ||
| ) | [static] |
Definition at line 3167 of file GlobalOpt.cpp.
References llvm::GlobalAlias::getAliasee(), llvm::GlobalValue::hasLocalLinkage(), hasMoreThanOneUseOtherThanLLVMUsed(), hasUseOtherThanLLVMUsed(), mayHaveOtherReferences(), llvm::AArch64ISD::Ret, and llvm::Value::stripPointerCasts().
| static GlobalVariable* InstallGlobalCtors | ( | GlobalVariable * | GCL, |
| const std::vector< Function * > & | Ctors | ||
| ) | [static] |
InstallGlobalCtors - Given a specified llvm.global_ctors list, install the specified array, returning the new global to use.
Definition at line 2205 of file GlobalOpt.cpp.
References llvm::GlobalVariable::eraseFromParent(), llvm::ConstantInt::get(), llvm::FunctionType::get(), llvm::ArrayType::get(), llvm::ConstantArray::get(), llvm::ConstantStruct::get(), llvm::ConstantExpr::getBitCast(), llvm::Value::getContext(), llvm::SequentialType::getElementType(), llvm::Module::getGlobalList(), llvm::GlobalVariable::getInitializer(), llvm::Type::getInt32Ty(), llvm::GlobalValue::getLinkage(), llvm::Constant::getNullValue(), llvm::GlobalValue::getParent(), llvm::GlobalVariable::getThreadLocalMode(), llvm::Value::getType(), llvm::GlobalValue::getType(), llvm::PointerType::getUnqual(), llvm::Type::getVoidTy(), llvm::GlobalVariable::isConstant(), llvm::Value::replaceAllUsesWith(), llvm::GlobalVariable::setInitializer(), llvm::Value::takeName(), and llvm::Value::use_empty().
| static bool isLeakCheckerRoot | ( | GlobalVariable * | GV | ) | [static] |
isLeakCheckerRoot - Is this global variable possibly used by a leak checker as a root? If so, we might not really want to eliminate the stores to it.
Definition at line 305 of file GlobalOpt.cpp.
References llvm::Type::ArrayTyID, llvm::StructType::element_begin(), llvm::StructType::element_end(), llvm::SmallVectorBase::empty(), llvm::SequentialType::getElementType(), llvm::GlobalValue::getType(), llvm::Type::getTypeID(), llvm::GlobalValue::hasPrivateLinkage(), I, llvm::StructType::isOpaque(), llvm::Type::PointerTyID, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::Type::StructTyID, and llvm::Type::VectorTyID.
Referenced by OptimizeAwayTrappingUsesOfLoads().
| static bool IsSafeComputationToRemove | ( | Value * | V, |
| const TargetLibraryInfo * | TLI | ||
| ) | [static] |
Given a value that is stored to a global but never read, determine whether it's safe to remove the store and the chain of computation that feeds the store.
Definition at line 353 of file GlobalOpt.cpp.
References llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::Value::hasOneUse(), I, llvm::isAllocationFn(), and llvm::Instruction::mayHaveSideEffects().
Referenced by CleanupPointerRootUsers().
isSafeSROAElementUse - Return true if the specified instruction is a safe user of a derived expression from a global that we want to SROA.
Definition at line 548 of file GlobalOpt.cpp.
References llvm::CallingConv::C, llvm::dyn_cast(), llvm::User::getNumOperands(), llvm::User::getOperand(), I, SafeToDestroyConstant(), llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by IsUserOfGlobalSafeForSRA().
isSimpleEnoughPointerToCommit - Return true if this constant is simple enough for us to understand. In particular, if it is a cast to anything other than from one pointer type to another pointer type, we punt. We basically just support direct accesses to globals and GEP's of globals. This should be kept up to date with CommitValueTo.
Definition at line 2349 of file GlobalOpt.cpp.
References llvm::ConstantFoldLoadThroughGEPConstantExpr(), llvm::dyn_cast(), llvm::GlobalVariable::getInitializer(), llvm::Value::getType(), llvm::GlobalVariable::hasUniqueInitializer(), llvm::ConstantInt::isZero(), and llvm::next().
| static bool isSimpleEnoughValueToCommit | ( | Constant * | C, |
| SmallPtrSet< Constant *, 8 > & | SimpleConstants, | ||
| const DataLayout * | TD | ||
| ) | [inline, static] |
Definition at line 2334 of file GlobalOpt.cpp.
References llvm::SmallPtrSet< PtrType, SmallSize >::insert(), and isSimpleEnoughValueToCommitHelper().
Referenced by isSimpleEnoughValueToCommitHelper().
| static bool isSimpleEnoughValueToCommitHelper | ( | Constant * | C, |
| SmallPtrSet< Constant *, 8 > & | SimpleConstants, | ||
| const DataLayout * | TD | ||
| ) | [static] |
isSimpleEnoughValueToCommit - Return true if the specified constant can be handled by the code generator. We don't want to generate something like: void *X = &X/42; because the code generator doesn't have a relocation that can handle that.
This function should be called if C was not found (but just got inserted) in SimpleConstants to avoid having to rescan the same constants all the time.
Definition at line 2279 of file GlobalOpt.cpp.
References llvm::CallingConv::C, llvm::User::getNumOperands(), llvm::ConstantExpr::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), llvm::IntToPtr, and isSimpleEnoughValueToCommit().
Referenced by isSimpleEnoughValueToCommit().
| static bool IsUserOfGlobalSafeForSRA | ( | User * | U, |
| GlobalValue * | GV | ||
| ) | [static] |
IsUserOfGlobalSafeForSRA - U is a direct user of the specified global value. Look at it and its uses and decide whether it is safe to SROA this global.
Definition at line 582 of file GlobalOpt.cpp.
References llvm::dyn_cast(), llvm::gep_type_begin(), llvm::gep_type_end(), llvm::User::getNumOperands(), llvm::generic_gep_type_iterator< ItTy >::getOperand(), llvm::User::getOperand(), llvm::ConstantInt::getZExtValue(), I, isSafeSROAElementUse(), llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by GlobalUsersSafeToSRA().
| static bool LoadUsesSimpleEnoughForHeapSRA | ( | const Value * | V, |
| SmallPtrSet< const PHINode *, 32 > & | LoadUsingPHIs, | ||
| SmallPtrSet< const PHINode *, 32 > & | LoadUsingPHIsPerLoad | ||
| ) | [static] |
LoadUsesSimpleEnoughForHeapSRA - Verify that all uses of V (a load, or a phi of a load) are simple enough to perform heap SRA on. This permits GEP's that index through the array and struct field, icmps of null, and PHIs.
Definition at line 1248 of file GlobalOpt.cpp.
References llvm::SmallPtrSet< PtrType, SmallSize >::insert(), llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by AllGlobalLoadUsesSimpleEnoughForHeapSRA().
| static bool mayHaveOtherReferences | ( | GlobalAlias & | GA, |
| const LLVMUsed & | U | ||
| ) | [static] |
Definition at line 3160 of file GlobalOpt.cpp.
References llvm::GlobalValue::hasLocalLinkage().
Referenced by hasUsesToReplace().
| static bool OptimizeAwayTrappingUsesOfLoads | ( | GlobalVariable * | GV, |
| Constant * | LV, | ||
| DataLayout * | TD, | ||
| TargetLibraryInfo * | TLI | ||
| ) | [static] |
OptimizeAwayTrappingUsesOfLoads - The specified global has only one non-null value stored into it. If there are uses of the loaded value that would trap if the loaded value is dynamically null, then we know that they cannot be reachable with a null optimize away the load.
Definition at line 938 of file GlobalOpt.cpp.
References CleanupConstantGlobalUsers(), CleanupPointerRootUsers(), llvm::dbgs(), DEBUG, llvm::GlobalVariable::eraseFromParent(), llvm::User::getOperand(), isLeakCheckerRoot(), LI, OptimizeAwayTrappingUsesOfValue(), llvm::Value::use_begin(), llvm::Value::use_empty(), and llvm::Value::use_end().
Referenced by OptimizeOnceStoredGlobal().
Definition at line 871 of file GlobalOpt.cpp.
References llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_size(), llvm::CallingConv::C, llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getArgument(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledValue(), llvm::ConstantExpr::getCast(), llvm::ConstantExpr::getGetElementPtr(), llvm::Value::getType(), I, LI, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SmallVectorImpl< T >::reserve(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::setArgument(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::setCalledFunction(), llvm::SmallVectorTemplateCommon< T >::size(), llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by OptimizeAwayTrappingUsesOfLoads().
| static GlobalVariable* OptimizeGlobalAddressOfMalloc | ( | GlobalVariable * | GV, |
| CallInst * | CI, | ||
| Type * | AllocTy, | ||
| ConstantInt * | NElements, | ||
| DataLayout * | TD, | ||
| TargetLibraryInfo * | TLI | ||
| ) | [static] |
OptimizeGlobalAddressOfMalloc - This function takes the specified global variable, and transforms the program as if it always contained the result of the specified malloc. Because it is always the result of the specified malloc, there is no reason to actually DO the malloc. Instead, turn the malloc into a global, and any loads of GV as uses of the new global.
Definition at line 1022 of file GlobalOpt.cpp.
References ConstantPropUsersOf(), llvm::BinaryOperator::CreateNot(), DEBUG, llvm::Instruction::eraseFromParent(), llvm::GlobalVariable::eraseFromParent(), llvm::errs(), llvm::ArrayType::get(), llvm::UndefValue::get(), llvm::ConstantExpr::getBitCast(), llvm::Value::getContext(), llvm::SequentialType::getElementType(), llvm::ConstantInt::getFalse(), llvm::Module::getGlobalList(), llvm::Type::getInt1Ty(), llvm::Value::getName(), llvm::LoadInst::getOrdering(), llvm::GlobalValue::getParent(), llvm::CmpInst::getPredicate(), llvm::LoadInst::getSynchScope(), llvm::GlobalVariable::getThreadLocalMode(), llvm::ConstantInt::getTrue(), llvm::GlobalValue::getType(), llvm::Value::getType(), llvm::Use::getUser(), llvm::ConstantInt::getZExtValue(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::GlobalValue::InternalLinkage, llvm::LoadInst::isUnordered(), LI, llvm_unreachable, llvm::Value::replaceAllUsesWith(), llvm::User::replaceUsesOfWith(), llvm::Instruction::use_back(), llvm::Value::use_back(), llvm::Value::use_begin(), and llvm::Value::use_empty().
Referenced by TryToOptimizeStoreOfMallocToGlobal().
| static bool OptimizeOnceStoredGlobal | ( | GlobalVariable * | GV, |
| Value * | StoredOnceVal, | ||
| AtomicOrdering | Ordering, | ||
| Module::global_iterator & | GVI, | ||
| DataLayout * | TD, | ||
| TargetLibraryInfo * | TLI | ||
| ) | [static] |
Definition at line 1763 of file GlobalOpt.cpp.
References llvm::extractMallocCall(), llvm::ConstantExpr::getBitCast(), llvm::GlobalVariable::getInitializer(), llvm::getMallocAllocatedType(), llvm::Value::getType(), llvm::Constant::isNullValue(), llvm::Type::isPointerTy(), OptimizeAwayTrappingUsesOfLoads(), llvm::Value::stripPointerCasts(), and TryToOptimizeStoreOfMallocToGlobal().
| static std::vector<Function*> ParseGlobalCtors | ( | GlobalVariable * | GV | ) | [static] |
ParseGlobalCtors - Given a llvm.global_ctors list that we can understand, return a list of the functions and null terminator as a vector.
Definition at line 2190 of file GlobalOpt.cpp.
References llvm::GlobalVariable::getInitializer(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::Constant::isNullValue(), llvm::User::op_begin(), and llvm::User::op_end().
| static GlobalVariable* PerformHeapAllocSRoA | ( | GlobalVariable * | GV, |
| CallInst * | CI, | ||
| Value * | NElems, | ||
| DataLayout * | TD, | ||
| const TargetLibraryInfo * | TLI | ||
| ) | [static] |
PerformHeapAllocSRoA - CI is an allocation of an array of structures. Break it up into multiple allocations of arrays of the fields.
InsertedScalarizedLoads - As we process loads, if we can't immediately update all uses of the load, keep track of what scalarized loads are inserted for a given load.
Definition at line 1474 of file GlobalOpt.cpp.
References llvm::PHINode::addIncoming(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT >, KeyT, ValueT, KeyInfoT >::begin(), llvm::BasicBlock::Create(), llvm::BranchInst::Create(), llvm::CallInst::CreateFree(), llvm::CallInst::CreateMalloc(), llvm::dbgs(), DEBUG, llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT >, KeyT, ValueT, KeyInfoT >::end(), llvm::Instruction::eraseFromParent(), llvm::GlobalVariable::eraseFromParent(), llvm::ConstantInt::get(), llvm::CallInst::getArgOperand(), llvm::BasicBlock::getContext(), llvm::Value::getContext(), llvm::StructType::getElementType(), llvm::SequentialType::getElementType(), GetHeapSROAValue(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::DataLayout::getIntPtrType(), llvm::getMallocAllocatedType(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::StructType::getNumElements(), llvm::PHINode::getNumIncomingValues(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::StructLayout::getSizeInBytes(), llvm::DataLayout::getStructLayout(), llvm::BasicBlock::getTerminator(), llvm::GlobalVariable::getThreadLocalMode(), getType(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::PointerType::getUnqual(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SLT, llvm::GlobalValue::InternalLinkage, LI, ReplaceUsesOfMallocWithGlobal(), RewriteUsesOfLoadForHeapSRoA(), llvm::BasicBlock::splitBasicBlock(), llvm::A64DB::ST, llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by TryToOptimizeStoreOfMallocToGlobal().
| static void RemoveNestAttribute | ( | Function * | F | ) | [static] |
Definition at line 2085 of file GlobalOpt.cpp.
References llvm::Function::getAttributes(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getAttributes(), llvm::Function::getContext(), llvm::Function::setAttributes(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::setAttributes(), StripNest(), llvm::Value::use_begin(), and llvm::Value::use_end().
| static void ReplaceUsesOfMallocWithGlobal | ( | Instruction * | Alloc, |
| GlobalVariable * | GV | ||
| ) | [static] |
ReplaceUsesOfMallocWithGlobal - The Alloc pointer is stored into GV somewhere. Transform all uses of the allocation into loads from the global and uses of the resultant pointer. Further, delete the store into GV. This assumes that these value pass the 'ValueIsOnlyUsedLocallyOrStoredToOneGlobal' predicate.
Definition at line 1205 of file GlobalOpt.cpp.
References llvm::Instruction::eraseFromParent(), llvm::Value::getName(), llvm::User::replaceUsesOfWith(), llvm::Value::use_begin(), and llvm::Value::use_empty().
Referenced by PerformHeapAllocSRoA().
| static void RewriteHeapSROALoadUser | ( | Instruction * | LoadUser, |
| DenseMap< Value *, std::vector< Value * > > & | InsertedScalarizedValues, | ||
| std::vector< std::pair< PHINode *, unsigned > > & | PHIsToRewrite | ||
| ) | [static] |
RewriteHeapSROALoadUser - Given a load instruction and a value derived from the load, rewrite the derived value to use the HeapSRoA'd load.
Definition at line 1393 of file GlobalOpt.cpp.
References llvm::GetElementPtrInst::Create(), GetHeapSROAValue(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by RewriteUsesOfLoadForHeapSRoA().
| static void RewriteUsesOfLoadForHeapSRoA | ( | LoadInst * | Load, |
| DenseMap< Value *, std::vector< Value * > > & | InsertedScalarizedValues, | ||
| std::vector< std::pair< PHINode *, unsigned > > & | PHIsToRewrite | ||
| ) | [static] |
RewriteUsesOfLoadForHeapSRoA - We are performing Heap SRoA on a global. Ptr is a value loaded from the global. Eliminate all uses of Ptr, making them use FieldGlobals instead. All uses of loaded values satisfy AllGlobalLoadUsesSimpleEnoughForHeapSRA.
Definition at line 1457 of file GlobalOpt.cpp.
References llvm::Instruction::eraseFromParent(), RewriteHeapSROALoadUser(), llvm::Value::use_begin(), llvm::Value::use_empty(), and llvm::Value::use_end().
Referenced by PerformHeapAllocSRoA().
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.
Definition at line 175 of file GlobalOpt.cpp.
References llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by AnalyzeGlobal(), CleanupConstantGlobalUsers(), CleanupPointerRootUsers(), and isSafeSROAElementUse().
| static void setUsedInitializer | ( | GlobalVariable & | V, |
| SmallPtrSet< GlobalValue *, 8 > | Init | ||
| ) | [static] |
Definition at line 3072 of file GlobalOpt.cpp.
References llvm::GlobalValue::AppendingLinkage, llvm::array_pod_sort(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::SmallPtrSet< PtrType, SmallSize >::begin(), compareNames(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::SmallPtrSet< PtrType, SmallSize >::end(), llvm::ArrayType::get(), llvm::ConstantArray::get(), llvm::ConstantExpr::getBitCast(), llvm::Value::getContext(), llvm::Type::getInt8PtrTy(), llvm::GlobalValue::getParent(), I, llvm::A64CC::NV, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::GlobalVariable::removeFromParent(), llvm::GlobalValue::setSection(), llvm::SmallVectorTemplateCommon< T >::size(), and llvm::Value::takeName().
| static GlobalVariable* SRAGlobal | ( | GlobalVariable * | GV, |
| const DataLayout & | TD | ||
| ) | [static] |
SRAGlobal - Perform scalar replacement of aggregates on the specified global variable. This opens the door for other optimizations by exposing the behavior of the program in a more fine-grained way. We have determined that this transformation is safe already. We return the first global variable we insert so that the caller can reprocess it.
Definition at line 663 of file GlobalOpt.cpp.
References llvm::GetElementPtrInst::Create(), llvm::dbgs(), DEBUG, llvm::iplist< NodeTy, Traits >::erase(), llvm::DataLayout::getABITypeAlignment(), llvm::PointerType::getAddressSpace(), llvm::GlobalValue::getAlignment(), llvm::Value::getContext(), llvm::StructLayout::getElementOffset(), llvm::ConstantExpr::getGetElementPtr(), llvm::Module::getGlobalList(), llvm::GlobalVariable::getInitializer(), llvm::Type::getInt32Ty(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::GlobalValue::getParent(), llvm::DataLayout::getStructLayout(), llvm::GlobalVariable::getThreadLocalMode(), llvm::GlobalValue::getType(), llvm::DataLayout::getTypeAllocSize(), GlobalUsersSafeToSRA(), llvm::GlobalValue::hasLocalLinkage(), llvm::Value::hasNUsesOrMore(), llvm::tgtok::In, llvm::iplist< NodeTy, Traits >::insert(), llvm::GlobalValue::InternalLinkage, llvm::GlobalVariable::isConstant(), llvm::MinAlign(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::GlobalValue::setAlignment(), llvm::Value::use_back(), and llvm::Value::use_empty().
| STATISTIC | ( | NumMarked | , |
| "Number of globals marked constant" | |||
| ) |
| STATISTIC | ( | NumUnnamed | , |
| "Number of globals marked unnamed_addr" | |||
| ) |
| STATISTIC | ( | NumHeapSRA | , |
| "Number of heap objects SRA'd" | |||
| ) |
| STATISTIC | ( | NumSubstitute | , |
| "Number of globals with initializers stored into them" | |||
| ) |
| STATISTIC | ( | NumDeleted | , |
| "Number of globals deleted" | |||
| ) |
| STATISTIC | ( | NumFnDeleted | , |
| "Number of functions deleted" | |||
| ) |
| STATISTIC | ( | NumGlobUses | , |
| "Number of global uses devirtualized" | |||
| ) |
| STATISTIC | ( | NumLocalized | , |
| "Number of globals localized" | |||
| ) |
| STATISTIC | ( | NumShrunkToBool | , |
| "Number of global vars shrunk to booleans" | |||
| ) |
| STATISTIC | ( | NumFastCallFns | , |
| "Number of functions converted to fastcc" | |||
| ) |
| STATISTIC | ( | NumCtorsEvaluated | , |
| "Number of static ctors evaluated" | |||
| ) |
| STATISTIC | ( | NumNestRemoved | , |
| "Number of nest attributes removed" | |||
| ) |
| STATISTIC | ( | NumAliasesResolved | , |
| "Number of global aliases resolved" | |||
| ) |
| STATISTIC | ( | NumAliasesRemoved | , |
| "Number of global aliases eliminated" | |||
| ) |
| STATISTIC | ( | NumCXXDtorsRemoved | , |
| "Number of global C++ destructors removed" | |||
| ) |
| static AttributeSet StripNest | ( | LLVMContext & | C, |
| const AttributeSet & | Attrs | ||
| ) | [static] |
Definition at line 2072 of file GlobalOpt.cpp.
References llvm::AttributeSet::getNumSlots(), llvm::AttributeSet::getSlotAttributes(), llvm::AttributeSet::getSlotIndex(), llvm::AttributeSet::hasAttribute(), llvm::Attribute::Nest, and llvm::AttributeSet::removeAttribute().
Referenced by RemoveNestAttribute().
| static AtomicOrdering StrongerOrdering | ( | AtomicOrdering | X, |
| AtomicOrdering | Y | ||
| ) | [static] |
StrongerOrdering - Return the stronger of the two ordering. If the two orderings are acquire and release, then return AcquireRelease.
Definition at line 165 of file GlobalOpt.cpp.
References llvm::Acquire, llvm::AcquireRelease, and llvm::Release.
Referenced by AnalyzeGlobal().
| static bool TryToOptimizeStoreOfMallocToGlobal | ( | GlobalVariable * | GV, |
| CallInst * | CI, | ||
| Type * | AllocTy, | ||
| AtomicOrdering | Ordering, | ||
| Module::global_iterator & | GVI, | ||
| DataLayout * | TD, | ||
| TargetLibraryInfo * | TLI | ||
| ) | [static] |
TryToOptimizeStoreOfMallocToGlobal - This function is called when we see a pointer global variable with a single value stored it that is a malloc or cast of malloc.
Definition at line 1662 of file GlobalOpt.cpp.
References AllGlobalLoadUsesSimpleEnoughForHeapSRA(), AllUsesOfLoadedValueWillTrapIfNull(), llvm::CallInst::CreateMalloc(), llvm::dyn_cast(), llvm::Instruction::eraseFromParent(), llvm::ConstantInt::get(), llvm::CallInst::getArgOperand(), llvm::Value::getContext(), llvm::DataLayout::getIntPtrType(), llvm::getMallocAllocatedType(), llvm::getMallocArraySize(), llvm::Value::getName(), llvm::StructType::getNumElements(), llvm::StructLayout::getSizeInBytes(), llvm::DataLayout::getStructLayout(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::Type::isSized(), llvm::NotAtomic, OptimizeGlobalAddressOfMalloc(), PerformHeapAllocSRoA(), llvm::Value::replaceAllUsesWith(), and ValueIsOnlyUsedLocallyOrStoredToOneGlobal().
Referenced by OptimizeOnceStoredGlobal().
| static bool TryToShrinkGlobalToBoolean | ( | GlobalVariable * | GV, |
| Constant * | OtherVal | ||
| ) | [static] |
TryToShrinkGlobalToBoolean - At this point, we have learned that the only two values ever stored into GV are its initializer and OtherVal. See if we can shrink the global into a boolean and select between the two values whenever it is used. This exposes the values to other scalar optimizations.
Definition at line 1799 of file GlobalOpt.cpp.
References llvm::SelectInst::Create(), llvm::dbgs(), DEBUG, llvm::Instruction::eraseFromParent(), llvm::GlobalVariable::eraseFromParent(), llvm::ConstantInt::get(), llvm::PointerType::getAddressSpace(), llvm::Value::getContext(), llvm::SequentialType::getElementType(), llvm::ConstantInt::getFalse(), llvm::Module::getGlobalList(), llvm::GlobalVariable::getInitializer(), llvm::Type::getInt1Ty(), llvm::Value::getName(), llvm::User::getOperand(), llvm::LoadInst::getOrdering(), llvm::GlobalValue::getParent(), llvm::LoadInst::getSynchScope(), llvm::GlobalVariable::getThreadLocalMode(), llvm::Value::getType(), llvm::GlobalValue::getType(), I, llvm::GlobalValue::InternalLinkage, llvm::Type::isFloatingPointTy(), llvm::Constant::isNullValue(), llvm::Type::isPointerTy(), llvm::Type::isVectorTy(), LI, llvm::Value::replaceAllUsesWith(), llvm::Value::takeName(), llvm::Value::use_back(), llvm::Value::use_begin(), llvm::Value::use_empty(), and llvm::Value::use_end().
| static bool ValueIsOnlyUsedLocallyOrStoredToOneGlobal | ( | const Instruction * | V, |
| const GlobalVariable * | GV, | ||
| SmallPtrSet< const PHINode *, 8 > & | PHIs | ||
| ) | [static] |
ValueIsOnlyUsedLocallyOrStoredToOneGlobal - Scan the use-list of V checking to make sure that there are no complex uses of V. We permit simple things like dereferencing the pointer, but not storing through the address, unless it is to the specified global.
Definition at line 1156 of file GlobalOpt.cpp.
References llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::SmallPtrSet< PtrType, SmallSize >::insert(), llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by TryToOptimizeStoreOfMallocToGlobal().
| Global Variable false |
Definition at line 95 of file GlobalOpt.cpp.
Definition at line 95 of file GlobalOpt.cpp.
| Global Variable Optimizer |
Definition at line 95 of file GlobalOpt.cpp.