LLVM  3.7.0
Macros | Functions | Variables
ArgumentPromotion.cpp File Reference
#include "llvm/Transforms/IPO.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/CallGraphSCCPass.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <set>
Include dependency graph for ArgumentPromotion.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "argpromotion"
 

Functions

 STATISTIC (NumArgumentsPromoted,"Number of pointer arguments promoted")
 
 STATISTIC (NumAggregatesPromoted,"Number of aggregate arguments promoted")
 
 STATISTIC (NumByValArgsPromoted,"Number of byval arguments promoted")
 
 STATISTIC (NumArgumentsDead,"Number of dead pointer args eliminated")
 
 INITIALIZE_PASS_BEGIN (ArgPromotion,"argpromotion","Promote 'by reference' arguments to scalars", false, false) INITIALIZE_PASS_END(ArgPromotion
 
static bool AllCallersPassInValidPointerForArgument (Argument *Arg)
 AllCallersPassInValidPointerForArgument - Return true if we can prove that all callees pass in a valid pointer for the specified function argument. More...
 
static bool IsPrefix (const ArgPromotion::IndicesVector &Prefix, const ArgPromotion::IndicesVector &Longer)
 Returns true if Prefix is a prefix of longer. More...
 
static bool PrefixIn (const ArgPromotion::IndicesVector &Indices, std::set< ArgPromotion::IndicesVector > &Set)
 Checks if Indices, or a prefix of Indices, is in Set. More...
 
static void MarkIndicesSafe (const ArgPromotion::IndicesVector &ToMark, std::set< ArgPromotion::IndicesVector > &Safe)
 Mark the given indices (ToMark) as safe in the given set of indices (Safe). More...
 

Variables

 argpromotion
 
Promote by reference arguments to scalars
 
Promote by reference arguments to false
 

Macro Definition Documentation

#define DEBUG_TYPE   "argpromotion"

Definition at line 54 of file ArgumentPromotion.cpp.

Function Documentation

static bool AllCallersPassInValidPointerForArgument ( Argument Arg)
static

AllCallersPassInValidPointerForArgument - Return true if we can prove that all callees pass in a valid pointer for the specified function argument.

Definition at line 331 of file ArgumentPromotion.cpp.

References llvm::CS, llvm::Argument::getArgNo(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getArgument(), llvm::Module::getDataLayout(), llvm::Argument::getParent(), llvm::GlobalValue::getParent(), llvm::isDereferenceablePointer(), and llvm::Value::users().

INITIALIZE_PASS_BEGIN ( ArgPromotion  ,
"argpromotion"  ,
"Promote 'by reference' arguments to scalars ,
false  ,
false   
)
static bool IsPrefix ( const ArgPromotion::IndicesVector &  Prefix,
const ArgPromotion::IndicesVector &  Longer 
)
static

Returns true if Prefix is a prefix of longer.

That means, Longer has a size that is greater than or equal to the size of prefix, and each of the elements in Prefix is the same as the corresponding elements in Longer.

This means it also returns true when Prefix and Longer are equal!

Definition at line 354 of file ArgumentPromotion.cpp.

References llvm::lltok::equal.

Referenced by MarkIndicesSafe(), and PrefixIn().

static void MarkIndicesSafe ( const ArgPromotion::IndicesVector &  ToMark,
std::set< ArgPromotion::IndicesVector > &  Safe 
)
static

Mark the given indices (ToMark) as safe in the given set of indices (Safe).

Marking safe usually means adding ToMark to Safe. However, if there is already a prefix of Indices in Safe, Indices are implicitely marked safe already. Furthermore, any indices that Indices is itself a prefix of, are removed from Safe (since they are implicitely safe because of Indices now).

Definition at line 382 of file ArgumentPromotion.cpp.

References IsPrefix().

static bool PrefixIn ( const ArgPromotion::IndicesVector &  Indices,
std::set< ArgPromotion::IndicesVector > &  Set 
)
static

Checks if Indices, or a prefix of Indices, is in Set.

Definition at line 363 of file ArgumentPromotion.cpp.

References IsPrefix().

STATISTIC ( NumArgumentsPromoted  ,
"Number of pointer arguments promoted"   
)
STATISTIC ( NumAggregatesPromoted  ,
"Number of aggregate arguments promoted"   
)
STATISTIC ( NumByValArgsPromoted  ,
"Number of byval arguments promoted"   
)
STATISTIC ( NumArgumentsDead  ,
"Number of dead pointer args eliminated"   
)

Variable Documentation

argpromotion

Definition at line 102 of file ArgumentPromotion.cpp.

Promote by reference arguments to false

Definition at line 102 of file ArgumentPromotion.cpp.

Promote by reference arguments to scalars

Definition at line 102 of file ArgumentPromotion.cpp.