LLVM API Documentation

GlobalOpt.cpp File Reference

#include "llvm/Transforms/IPO.h"
#include "llvm/CallingConv.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/Module.h"
#include "llvm/Pass.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm>

Include dependency graph for GlobalOpt.cpp:

Go to the source code of this file.

Defines

#define DEBUG_TYPE   "globalopt"

Functions

 STATISTIC (NumMarked,"Number of globals marked constant")
 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")
ModulePassllvm::createGlobalOptimizerPass ()
static bool ConstantIsDead (Constant *C)
static bool AnalyzeGlobal (Value *V, GlobalStatus &GS, SmallPtrSet< PHINode *, 16 > &PHIUsers)
static ConstantgetAggregateConstantElement (Constant *Agg, Constant *Idx)
static bool CleanupConstantGlobalUsers (Value *V, Constant *Init)
static bool isSafeSROAElementUse (Value *V)
static bool IsUserOfGlobalSafeForSRA (User *U, GlobalValue *GV)
static bool GlobalUsersSafeToSRA (GlobalValue *GV)
static GlobalVariableSRAGlobal (GlobalVariable *GV, const TargetData &TD)
static bool AllUsesOfValueWillTrapIfNull (Value *V, SmallPtrSet< PHINode *, 8 > &PHIs)
static bool AllUsesOfLoadedValueWillTrapIfNull (GlobalVariable *GV)
static bool OptimizeAwayTrappingUsesOfValue (Value *V, Constant *NewV)
static bool OptimizeAwayTrappingUsesOfLoads (GlobalVariable *GV, Constant *LV)
static void ConstantPropUsersOf (Value *V)
static GlobalVariableOptimizeGlobalAddressOfMalloc (GlobalVariable *GV, MallocInst *MI)
static bool ValueIsOnlyUsedLocallyOrStoredToOneGlobal (Instruction *V, GlobalVariable *GV, SmallPtrSet< PHINode *, 8 > &PHIs)
static void ReplaceUsesOfMallocWithGlobal (Instruction *Alloc, GlobalVariable *GV)
static bool LoadUsesSimpleEnoughForHeapSRA (Value *V, SmallPtrSet< PHINode *, 32 > &LoadUsingPHIs)
static bool AllGlobalLoadUsesSimpleEnoughForHeapSRA (GlobalVariable *GV, MallocInst *MI)
static ValueGetHeapSROAValue (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 GlobalVariablePerformHeapAllocSRoA (GlobalVariable *GV, MallocInst *MI)
static bool TryToOptimizeStoreOfMallocToGlobal (GlobalVariable *GV, MallocInst *MI, Module::global_iterator &GVI, TargetData &TD)
static bool OptimizeOnceStoredGlobal (GlobalVariable *GV, Value *StoredOnceVal, Module::global_iterator &GVI, TargetData &TD)
static bool TryToShrinkGlobalToBoolean (GlobalVariable *GV, Constant *OtherVal)
static bool OnlyCalledDirectly (Function *F)
static void ChangeCalleesToFastCall (Function *F)
static AttrListPtr StripNest (const AttrListPtr &Attrs)
static void RemoveNestAttribute (Function *F)
static std::vector< Function * > ParseGlobalCtors (GlobalVariable *GV)
static GlobalVariableInstallGlobalCtors (GlobalVariable *GCL, const std::vector< Function * > &Ctors)
static ConstantgetVal (DenseMap< Value *, Constant * > &ComputedValues, Value *V)
static bool isSimpleEnoughPointerToCommit (Constant *C)
static ConstantEvaluateStoreInto (Constant *Init, Constant *Val, ConstantExpr *Addr, unsigned OpNo)
static void CommitValueTo (Constant *Val, Constant *Addr)
static ConstantComputeLoadResult (Constant *P, const DenseMap< Constant *, Constant * > &Memory)
static bool EvaluateFunction (Function *F, Constant *&RetVal, const std::vector< Constant * > &ActualArgs, std::vector< Function * > &CallStack, DenseMap< Constant *, Constant * > &MutatedMemory, std::vector< GlobalVariable * > &AllocaTmps)
static bool EvaluateStaticConstructor (Function *F)

Variables

static RegisterPass< GlobalOpt > X ("globalopt","Global Variable Optimizer")


Define Documentation

#define DEBUG_TYPE   "globalopt"

Definition at line 16 of file GlobalOpt.cpp.


Function Documentation

static bool AllGlobalLoadUsesSimpleEnoughForHeapSRA ( GlobalVariable GV,
MallocInst MI 
) [static]

static bool AllUsesOfLoadedValueWillTrapIfNull ( 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 651 of file GlobalOpt.cpp.

References AllUsesOfValueWillTrapIfNull(), E, LI, llvm::Value::use_begin(), and llvm::Value::use_end().

Referenced by TryToOptimizeStoreOfMallocToGlobal().

static bool AllUsesOfValueWillTrapIfNull ( Value V,
SmallPtrSet< 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 609 of file GlobalOpt.cpp.

References CI, E, llvm::Constant::getOperand(), II, llvm::SmallPtrSet< PtrType, SmallSize >::insert(), llvm::Value::use_begin(), and llvm::Value::use_end().

Referenced by AllUsesOfLoadedValueWillTrapIfNull().

static bool AnalyzeGlobal ( Value V,
GlobalStatus &  GS,
SmallPtrSet< 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 157 of file GlobalOpt.cpp.

References llvm::CallingConv::C, ConstantIsDead(), E, F, llvm::Constant::getOperand(), GV, I, if(), llvm::SmallPtrSet< PtrType, SmallSize >::insert(), LI, 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 1776 of file GlobalOpt.cpp.

References E, Fast, llvm::CallSite::setCallingConv(), llvm::Value::use_begin(), llvm::Value::use_end(), and User.

static bool CleanupConstantGlobalUsers ( Value V,
Constant Init 
) [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 281 of file GlobalOpt.cpp.

References BitCast, llvm::CallingConv::C, Changed, llvm::ConstantFoldInstruction(), llvm::ConstantFoldLoadThroughGEPConstantExpr(), ConstantIsDead(), E, llvm::MachineInstr::eraseFromParent(), llvm::ConstantExpr::getOpcode(), LI, MI, llvm::Value::use_begin(), and llvm::Value::use_end().

Referenced by OptimizeAwayTrappingUsesOfLoads().

static void CommitValueTo ( Constant Val,
Constant Addr 
) [static]

CommitValueTo - We have decided that Addr (which satisfies the predicate isSimpleEnoughPointerToCommit) should get Val as its value. Make it happen.

Definition at line 2066 of file GlobalOpt.cpp.

References EvaluateStoreInto(), llvm::GlobalVariable::getInitializer(), llvm::Constant::getOperand(), llvm::GlobalVariable::hasInitializer(), and llvm::GlobalVariable::setInitializer().

Referenced by EvaluateStaticConstructor().

static Constant* ComputeLoadResult ( Constant P,
const DenseMap< Constant *, Constant * > &  Memory 
) [static]

ComputeLoadResult - Return the value that would be computed by a load from P after the stores reflected by 'memory' have been performed. If we can't decide, return null.

Definition at line 2084 of file GlobalOpt.cpp.

References llvm::ConstantFoldLoadThroughGEPConstantExpr(), llvm::DenseMap< KeyT, ValueT, KeyInfoT, ValueInfoT >::end(), llvm::DenseMap< KeyT, ValueT, KeyInfoT, ValueInfoT >::find(), llvm::GlobalVariable::getInitializer(), llvm::GlobalVariable::hasInitializer(), I, and if().

Referenced by EvaluateFunction().

static bool ConstantIsDead ( Constant C  )  [static]

ConstantIsDead - Return true if the specified constant is (transitively) dead. The constant may be used by other constants (e.g. constant arrays and constant exprs) as long as they are dead, but it cannot be used by anything else.

Definition at line 141 of file GlobalOpt.cpp.

References E, llvm::Value::use_begin(), and llvm::Value::use_end().

Referenced by AnalyzeGlobal(), CleanupConstantGlobalUsers(), and isSafeSROAElementUse().

static void ConstantPropUsersOf ( Value V  )  [static]

ConstantPropUsersOf - Walk the use list of V, constant folding all of the instructions that are foldable.

Definition at line 787 of file GlobalOpt.cpp.

References llvm::ConstantFoldInstruction(), E, I, llvm::Value::use_begin(), and llvm::Value::use_end().

Referenced by OptimizeGlobalAddressOfMalloc().

static bool EvaluateFunction ( Function F,
Constant *&  RetVal,
const std::vector< Constant * > &  ActualArgs,
std::vector< Function * > &  CallStack,
DenseMap< Constant *, Constant * > &  MutatedMemory,
std::vector< GlobalVariable * > &  AllocaTmps 
) [static]

EvaluateFunction - Evaluate a call to function F, returning true if successful, false if we can't evaluate it. ActualArgs contains the formal arguments for the function.

Values - As we compute SSA register values, we store their contents here.

ExecutedBlocks - We only handle non-looping, non-recursive code. As such, we can only evaluate any one basic block at most once. This set keeps track of what we have executed so we can detect recursive cases etc.

Definition at line 2113 of file GlobalOpt.cpp.

References AI, llvm::Function::arg_begin(), llvm::Function::arg_end(), llvm::BasicBlock::begin(), llvm::Function::begin(), llvm::CallingConv::C, CI, ComputeLoadResult(), llvm::ConstantFoldCall(), llvm::dyn_cast(), E, llvm::SequentialType::getElementType(), llvm::Function::getFunctionType(), llvm::PHINode::getIncomingValueForBlock(), llvm::Value::getName(), llvm::Constant::getOperand(), llvm::AllocationInst::getType(), llvm::ConstantStruct::getType(), getVal(), llvm::ConstantInt::getZExtValue(), llvm::SmallPtrSet< PtrType, SmallSize >::insert(), llvm::AllocationInst::isArrayAllocation(), llvm::Function::isDeclaration(), isSimpleEnoughPointerToCommit(), llvm::FunctionType::isVarArg(), LI, llvm::User::op_begin(), llvm::User::op_end(), llvm::Function::size(), Ty, Val, and Values.

Referenced by EvaluateStaticConstructor().

static bool EvaluateStaticConstructor ( Function F  )  [static]

EvaluateStaticConstructor - Evaluate static constructors in the function, if we can. Return true if we can, false otherwise.

MutatedMemory - For each store we execute, we update this map. Loads check this to get the most up-to-date value. If evaluation is successful, this state is committed to the process.

AllocaTmps - To 'execute' an alloca, we create a temporary global variable to represent its body. This vector is needed so we can delete the temporary globals when we are done.

CallStack - This is used to detect recursion. In pathological situations we could hit exponential behavior, but at least there is nothing unbounded.

Definition at line 2283 of file GlobalOpt.cpp.

References llvm::DenseMap< KeyT, ValueT, KeyInfoT, ValueInfoT >::begin(), CommitValueTo(), DOUT, E, llvm::DenseMap< KeyT, ValueT, KeyInfoT, ValueInfoT >::end(), EvaluateFunction(), llvm::Value::getName(), llvm::GlobalValue::getType(), I, llvm::Value::replaceAllUsesWith(), llvm::DenseMap< KeyT, ValueT, KeyInfoT, ValueInfoT >::size(), and llvm::Value::use_empty().

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 2003 of file GlobalOpt.cpp.

References CI, llvm::StructType::getElementType(), llvm::StructType::getNumElements(), llvm::User::getNumOperands(), llvm::Constant::getOperand(), llvm::Value::getType(), llvm::ConstantInt::getZExtValue(), Idx, llvm::StructType::isPacked(), llvm::User::op_begin(), and llvm::User::op_end().

Referenced by CommitValueTo().

static Constant* getAggregateConstantElement ( Constant Agg,
Constant Idx 
) [static]

static Value* GetHeapSROAValue ( Value V,
unsigned  FieldNo,
DenseMap< Value *, std::vector< Value * > > &  InsertedScalarizedValues,
std::vector< std::pair< PHINode *, unsigned > > &  PHIsToRewrite 
) [static]

static Constant* getVal ( DenseMap< Value *, Constant * > &  ComputedValues,
Value V 
) [static]

Definition at line 1969 of file GlobalOpt.cpp.

References R.

Referenced by EvaluateFunction().

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 447 of file GlobalOpt.cpp.

References E, IsUserOfGlobalSafeForSRA(), llvm::Value::use_begin(), and llvm::Value::use_end().

Referenced by SRAGlobal().

static GlobalVariable* InstallGlobalCtors ( GlobalVariable GCL,
const std::vector< Function * > &  Ctors 
) [static]

static bool isSafeSROAElementUse ( Value V  )  [static]

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 352 of file GlobalOpt.cpp.

References llvm::CallingConv::C, ConstantIsDead(), llvm::dyn_cast(), E, llvm::User::getNumOperands(), llvm::User::getOperand(), I, llvm::Value::use_begin(), and llvm::Value::use_end().

Referenced by IsUserOfGlobalSafeForSRA().

static bool isSimpleEnoughPointerToCommit ( Constant C  )  [static]

isSimpleEnoughPointerToCommit - Return true if this constant is simple enough for us to understand. In particular, if it is a cast of something, 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 1981 of file GlobalOpt.cpp.

References llvm::ConstantFoldLoadThroughGEPConstantExpr(), llvm::GlobalVariable::getInitializer(), llvm::GlobalValue::hasExternalLinkage(), llvm::GlobalVariable::hasInitializer(), llvm::GlobalValue::hasInternalLinkage(), and llvm::GlobalVariable::isDeclaration().

Referenced by EvaluateFunction().

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 386 of file GlobalOpt.cpp.

References llvm::dyn_cast(), E, llvm::gep_type_begin(), llvm::gep_type_end(), llvm::User::getNumOperands(), getOpcode(), llvm::generic_gep_type_iterator< ItTy >::getOperand(), llvm::User::getOperand(), llvm::ConstantInt::getZExtValue(), I, Idx, isSafeSROAElementUse(), llvm::Value::use_begin(), and llvm::Value::use_end().

Referenced by GlobalUsersSafeToSRA().

static bool LoadUsesSimpleEnoughForHeapSRA ( Value V,
SmallPtrSet< PHINode *, 32 > &  LoadUsingPHIs 
) [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 1019 of file GlobalOpt.cpp.

References E, llvm::SmallPtrSet< PtrType, SmallSize >::insert(), llvm::Value::use_begin(), and llvm::Value::use_end().

Referenced by AllGlobalLoadUsesSimpleEnoughForHeapSRA().

static bool OnlyCalledDirectly ( Function F  )  [static]

OnlyCalledDirectly - Return true if the specified function is only called directly. In other words, its address is never taken.

Definition at line 1760 of file GlobalOpt.cpp.

References llvm::dyn_cast(), E, llvm::User::op_begin(), llvm::User::op_end(), llvm::Value::use_begin(), and llvm::Value::use_end().

static bool OptimizeAwayTrappingUsesOfLoads ( GlobalVariable GV,
Constant LV 
) [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 735 of file GlobalOpt.cpp.

References Changed, CleanupConstantGlobalUsers(), DOUT, E, llvm::GlobalVariable::eraseFromParent(), llvm::Instruction::eraseFromParent(), L, LI, OptimizeAwayTrappingUsesOfValue(), llvm::Value::use_begin(), llvm::Value::use_empty(), and llvm::Value::use_end().

Referenced by OptimizeOnceStoredGlobal().

static bool OptimizeAwayTrappingUsesOfValue ( Value V,
Constant NewV 
) [static]

static GlobalVariable* OptimizeGlobalAddressOfMalloc ( GlobalVariable GV,
MallocInst MI 
) [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 806 of file GlobalOpt.cpp.

References CI, ConstantPropUsersOf(), llvm::GetElementPtrInst::Create(), llvm::BinaryOperator::CreateNot(), DOUT, llvm::GlobalVariable::eraseFromParent(), llvm::Instruction::eraseFromParent(), llvm::UndefValue::get(), llvm::ArrayType::get(), llvm::ConstantExpr::getBitCast(), llvm::SequentialType::getElementType(), llvm::ConstantInt::getFalse(), llvm::Module::getGlobalList(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::GlobalValue::getParent(), llvm::CmpInst::getPredicate(), llvm::ConstantInt::getTrue(), llvm::GlobalValue::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, Indices, llvm::Type::Int1Ty, llvm::Type::Int32Ty, llvm::GlobalValue::InternalLinkage, llvm::GlobalVariable::isThreadLocal(), LI, LV, llvm::Value::replaceAllUsesWith(), llvm::Value::use_back(), and llvm::Value::use_empty().

Referenced by TryToOptimizeStoreOfMallocToGlobal().

static bool OptimizeOnceStoredGlobal ( GlobalVariable GV,
Value StoredOnceVal,
Module::global_iterator &  GVI,
TargetData TD 
) [static]

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 1898 of file GlobalOpt.cpp.

References llvm::GlobalVariable::getInitializer(), llvm::User::getNumOperands(), llvm::Constant::getOperand(), llvm::User::op_begin(), and llvm::User::op_end().

static GlobalVariable* PerformHeapAllocSRoA ( GlobalVariable GV,
MallocInst MI 
) [static]

static void RemoveNestAttribute ( Function F  )  [static]

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 975 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 1151 of file GlobalOpt.cpp.

References llvm::GetElementPtrInst::Create(), E, GetHeapSROAValue(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::Value::getType(), InsertPos, llvm::Value::replaceAllUsesWith(), llvm::tie(), 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 1218 of file GlobalOpt.cpp.

References E, llvm::Instruction::eraseFromParent(), RewriteHeapSROALoadUser(), llvm::Value::use_begin(), llvm::Value::use_empty(), and llvm::Value::use_end().

Referenced by PerformHeapAllocSRoA().

static GlobalVariable* SRAGlobal ( GlobalVariable GV,
const TargetData TD 
) [static]

STATISTIC ( NumNestRemoved  ,
"Number of nest attributes removed"   
)

STATISTIC ( NumCtorsEvaluated  ,
"Number of static ctors evaluated"   
)

STATISTIC ( NumFastCallFns  ,
"Number of functions converted to fastcc"   
)

STATISTIC ( NumShrunkToBool  ,
"Number of global vars shrunk to booleans"   
)

STATISTIC ( NumLocalized  ,
"Number of globals localized"   
)

STATISTIC ( NumGlobUses  ,
"Number of global uses devirtualized"   
)

STATISTIC ( NumFnDeleted  ,
"Number of functions deleted"   
)

STATISTIC ( NumDeleted  ,
"Number of globals deleted"   
)

STATISTIC ( NumSubstitute  ,
"Number of globals with initializers stored into them"   
)

STATISTIC ( NumHeapSRA  ,
"Number of heap objects SRA'd"   
)

<
STATISTIC ( NumSRA  ,
"Number of aggregate globals broken into scalars"   
)