//===- Local.cpp - Compute a local data structure graph for a function ----===//
//
// 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.
//
//===----------------------------------------------------------------------===//
//
// Compute the local version of the data structure graph for a function. The
// external interface to this file is the DSGraph constructor.
//
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/DataStructure/DataStructure.h"
#include "llvm/Analysis/DataStructure/DSGraph.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h"
#include "llvm/Intrinsics.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Timer.h"
#include <iostream>
// FIXME: This should eventually be a FunctionPass that is automatically
// aggregated into a Pass.
//
#include "llvm/Module.h"
using namespace llvm;
static RegisterPass<LocalDataStructures>
X("datastructure", "Local Data Structure Analysis");
static cl::opt<bool>
TrackIntegersAsPointers("dsa-track-integers", cl::Hidden,
cl::desc("If this is set, track integers as potential pointers"));
static cl::list<std::string>
AllocList("dsa-alloc-list",
cl::value_desc("list"),
cl::desc("List of functions that allocate memory from the heap"),
cl::CommaSeparated, cl::Hidden);
static cl::list<std::string>
FreeList("dsa-free-list",
cl::value_desc("list"),
cl::desc("List of functions that free memory from the heap"),
cl::CommaSeparated, cl::Hidden);
namespace llvm {
namespace DS {
// isPointerType - Return true if this type is big enough to hold a pointer.
bool isPointerType(const Type *Ty) {
if (isa<PointerType>(Ty))
return true;
else if (TrackIntegersAsPointers && Ty->isPrimitiveType() &&Ty->isInteger())
return Ty->getPrimitiveSize() >= PointerSize;
return false;
}
}}
using namespace DS;
namespace {
cl::opt<bool>
DisableDirectCallOpt("disable-direct-call-dsopt", cl::Hidden,
cl::desc("Disable direct call optimization in "
"DSGraph construction"));
cl::opt