LLVM API Documentation

Defines | 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/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.


#define DEBUG_TYPE   "argpromotion"


 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, const DataLayout *DL)
static bool IsPrefix (const ArgPromotion::IndicesVector &Prefix, const ArgPromotion::IndicesVector &Longer)
static bool PrefixIn (const ArgPromotion::IndicesVector &Indices, std::set< ArgPromotion::IndicesVector > &Set)
 Checks if Indices, or a prefix of Indices, is in Set.
static void MarkIndicesSafe (const ArgPromotion::IndicesVector &ToMark, std::set< ArgPromotion::IndicesVector > &Safe)


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

Define Documentation

#define DEBUG_TYPE   "argpromotion"

Definition at line 53 of file ArgumentPromotion.cpp.

Function Documentation

static bool AllCallersPassInValidPointerForArgument ( Argument Arg,
const DataLayout DL 
) [static]

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

Definition at line 235 of file ArgumentPromotion.cpp.

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

"argpromotion"  ,
"Promote 'by reference' arguments to scalars ,
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 258 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 286 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 267 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

Definition at line 100 of file ArgumentPromotion.cpp.

Promote by reference arguments to false

Definition at line 100 of file ArgumentPromotion.cpp.

Promote by reference arguments to scalars

Definition at line 100 of file ArgumentPromotion.cpp.