From 2957f129a7390a068610e9af5a079c6fa1bead24 Mon Sep 17 00:00:00 2001 From: John Criswell Date: Wed, 13 Dec 2006 19:41:57 +0000 Subject: Remove DSA. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32550 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/DataStructure/DataStructureOpt.cpp | 102 ------------------------ 1 file changed, 102 deletions(-) delete mode 100644 lib/Analysis/DataStructure/DataStructureOpt.cpp (limited to 'lib/Analysis/DataStructure/DataStructureOpt.cpp') diff --git a/lib/Analysis/DataStructure/DataStructureOpt.cpp b/lib/Analysis/DataStructure/DataStructureOpt.cpp deleted file mode 100644 index 85da1763ac..0000000000 --- a/lib/Analysis/DataStructure/DataStructureOpt.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//===- DataStructureOpt.cpp - Data Structure Analysis Based Optimizations -===// -// -// 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. -// -//===----------------------------------------------------------------------===// -// -// This pass uses DSA to a series of simple optimizations, like marking -// unwritten global variables 'constant'. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Analysis/DataStructure/DataStructure.h" -#include "llvm/Analysis/DataStructure/DSGraph.h" -#include "llvm/Analysis/Passes.h" -#include "llvm/Module.h" -#include "llvm/Constant.h" -#include "llvm/Type.h" -#include "llvm/ADT/Statistic.h" -using namespace llvm; - -namespace { - Statistic - NumGlobalsConstanted("ds-opt", "Number of globals marked constant"); - Statistic - NumGlobalsIsolated("ds-opt", "Number of globals with references dropped"); - - class DSOpt : public ModulePass { - TDDataStructures *TD; - public: - bool runOnModule(Module &M) { - TD = &getAnalysis(); - bool Changed = OptimizeGlobals(M); - return Changed; - } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(); // Uses TD Datastructures - AU.addPreserved(); // Preserves local... - AU.addPreserved(); // Preserves bu... - AU.addPreserved(); // Preserves td... - } - - private: - bool OptimizeGlobals(Module &M); - }; - - RegisterPass X("ds-opt", "DSA-based simple optimizations"); -} - -ModulePass *llvm::createDSOptPass() { return new DSOpt(); } - -/// OptimizeGlobals - This method uses information taken from DSA to optimize -/// global variables. -/// -bool DSOpt::OptimizeGlobals(Module &M) { - DSGraph &GG = TD->getGlobalsGraph(); - const DSGraph::ScalarMapTy &SM = GG.getScalarMap(); - bool Changed = false; - - for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) - if (!I->isExternal()) { // Loop over all of the non-external globals... - // Look up the node corresponding to this global, if it exists. - DSNode *GNode = 0; - DSGraph::ScalarMapTy::const_iterator SMI = SM.find(I); - if (SMI != SM.end()) GNode = SMI->second.getNode(); - - if (GNode == 0 && I->hasInternalLinkage()) { - // If there is no entry in the scalar map for this global, it was never - // referenced in the program. If it has internal linkage, that means we - // can delete it. We don't ACTUALLY want to delete the global, just - // remove anything that references the global: later passes will take - // care of nuking it. - if (!I->use_empty()) { - I->replaceAllUsesWith(Constant::getNullValue((Type*)I->getType())); - ++NumGlobalsIsolated; - } - } else if (GNode && GNode->isComplete()) { - - // If the node has not been read or written, and it is not externally - // visible, kill any references to it so it can be DCE'd. - if (!GNode->isModified() && !GNode->isRead() &&I->hasInternalLinkage()){ - if (!I->use_empty()) { - I->replaceAllUsesWith(Constant::getNullValue((Type*)I->getType())); - ++NumGlobalsIsolated; - } - } - - // We expect that there will almost always be a node for this global. - // If there is, and the node doesn't have the M bit set, we can set the - // 'constant' bit on the global. - if (!GNode->isModified() && !I->isConstant()) { - I->setConstant(true); - ++NumGlobalsConstanted; - Changed = true; - } - } - } - return Changed; -} -- cgit v1.2.3-18-g5258