summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2011-10-17 17:17:43 +0000
committerDevang Patel <dpatel@apple.com>2011-10-17 17:17:43 +0000
commit827454e6e28cfed93db990b03b720ef7c23e6917 (patch)
treeb055134e328951670ef6e22d2e691f73e3c7d4c6
parent1e8ba3fa21326de4ef5bf908f6bfbf2852e04794 (diff)
downloadllvm-827454e6e28cfed93db990b03b720ef7c23e6917.tar.gz
llvm-827454e6e28cfed93db990b03b720ef7c23e6917.tar.bz2
llvm-827454e6e28cfed93db990b03b720ef7c23e6917.tar.xz
svn mv Target/ARM/ARMGlobalMerge.cpp Transforms/Scalar/GlobalMerge.cpp
There is no reason to have simple IR level pass in lib/Target. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142200 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/InitializePasses.h1
-rw-r--r--include/llvm/Transforms/Scalar.h2
-rw-r--r--lib/Target/ARM/ARMTargetMachine.cpp3
-rw-r--r--lib/Transforms/Scalar/GlobalMerge.cpp (renamed from lib/Target/ARM/ARMGlobalMerge.cpp)33
4 files changed, 25 insertions, 14 deletions
diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h
index c91fbf8de8..3a926dbbc7 100644
--- a/include/llvm/InitializePasses.h
+++ b/include/llvm/InitializePasses.h
@@ -136,6 +136,7 @@ void initializeLoopRotatePass(PassRegistry&);
void initializeLoopSimplifyPass(PassRegistry&);
void initializeLoopSplitterPass(PassRegistry&);
void initializeLoopStrengthReducePass(PassRegistry&);
+void initializeGlobalMergePass(PassRegistry&);
void initializeLoopUnrollPass(PassRegistry&);
void initializeLoopUnswitchPass(PassRegistry&);
void initializeLoopIdiomRecognizePass(PassRegistry&);
diff --git a/include/llvm/Transforms/Scalar.h b/include/llvm/Transforms/Scalar.h
index b1536f906d..5c0e9c66fb 100644
--- a/include/llvm/Transforms/Scalar.h
+++ b/include/llvm/Transforms/Scalar.h
@@ -112,6 +112,8 @@ Pass *createLICMPass();
//
Pass *createLoopStrengthReducePass(const TargetLowering *TLI = 0);
+Pass *createGlobalMergePass(const TargetLowering *TLI = 0);
+
//===----------------------------------------------------------------------===//
//
// LoopUnswitch - This pass is a simple loop unswitching pass.
diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp
index 96b1e89b0d..cf1432d64f 100644
--- a/lib/Target/ARM/ARMTargetMachine.cpp
+++ b/lib/Target/ARM/ARMTargetMachine.cpp
@@ -20,6 +20,7 @@
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Target/TargetOptions.h"
+#include "llvm/Transforms/Scalar.h"
using namespace llvm;
static cl::opt<bool>
@@ -97,7 +98,7 @@ ThumbTargetMachine::ThumbTargetMachine(const Target &T, StringRef TT,
bool ARMBaseTargetMachine::addPreISel(PassManagerBase &PM,
CodeGenOpt::Level OptLevel) {
if (OptLevel != CodeGenOpt::None && EnableGlobalMerge)
- PM.add(createARMGlobalMergePass(getTargetLowering()));
+ PM.add(createGlobalMergePass(getTargetLowering()));
return false;
}
diff --git a/lib/Target/ARM/ARMGlobalMerge.cpp b/lib/Transforms/Scalar/GlobalMerge.cpp
index 5f863ea241..0772b48729 100644
--- a/lib/Target/ARM/ARMGlobalMerge.cpp
+++ b/lib/Transforms/Scalar/GlobalMerge.cpp
@@ -1,4 +1,4 @@
-//===-- ARMGlobalMerge.cpp - Internal globals merging --------------------===//
+//===-- GlobalMerge.cpp - Internal globals merging -----------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -51,9 +51,8 @@
// note that we saved 2 registers here almostly "for free".
// ===---------------------------------------------------------------------===//
-#define DEBUG_TYPE "arm-global-merge"
-#include "ARM.h"
-#include "llvm/CodeGen/Passes.h"
+#define DEBUG_TYPE "global-merge"
+#include "llvm/Transforms/Scalar.h"
#include "llvm/Attributes.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
@@ -66,10 +65,12 @@
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLowering.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
+#include "llvm/ADT/Statistic.h"
using namespace llvm;
+STATISTIC(NumMerged , "Number of globals merged");
namespace {
- class ARMGlobalMerge : public FunctionPass {
+ class GlobalMerge : public FunctionPass {
/// TLI - Keep a pointer of a TargetLowering to consult for determining
/// target type sizes.
const TargetLowering *TLI;
@@ -79,8 +80,10 @@ namespace {
public:
static char ID; // Pass identification, replacement for typeid.
- explicit ARMGlobalMerge(const TargetLowering *tli)
- : FunctionPass(ID), TLI(tli) {}
+ explicit GlobalMerge(const TargetLowering *tli = 0)
+ : FunctionPass(ID), TLI(tli) {
+ initializeGlobalMergePass(*PassRegistry::getPassRegistry());
+ }
virtual bool doInitialization(Module &M);
virtual bool runOnFunction(Function &F);
@@ -109,9 +112,12 @@ namespace {
};
} // end anonymous namespace
-char ARMGlobalMerge::ID = 0;
+char GlobalMerge::ID = 0;
+INITIALIZE_PASS(GlobalMerge, "global-merge",
+ "Global Merge", false, false)
+
-bool ARMGlobalMerge::doMerge(SmallVectorImpl<GlobalVariable*> &Globals,
+bool GlobalMerge::doMerge(SmallVectorImpl<GlobalVariable*> &Globals,
Module &M, bool isConst) const {
const TargetData *TD = TLI->getTargetData();
@@ -153,6 +159,7 @@ bool ARMGlobalMerge::doMerge(SmallVectorImpl<GlobalVariable*> &Globals,
Constant *GEP = ConstantExpr::getInBoundsGetElementPtr(MergedGV, Idx);
Globals[k]->replaceAllUsesWith(GEP);
Globals[k]->eraseFromParent();
+ NumMerged++;
}
i = j;
}
@@ -161,7 +168,7 @@ bool ARMGlobalMerge::doMerge(SmallVectorImpl<GlobalVariable*> &Globals,
}
-bool ARMGlobalMerge::doInitialization(Module &M) {
+bool GlobalMerge::doInitialization(Module &M) {
SmallVector<GlobalVariable*, 16> Globals, ConstGlobals, BSSGlobals;
const TargetData *TD = TLI->getTargetData();
unsigned MaxOffset = TLI->getMaximalGlobalOffset();
@@ -210,10 +217,10 @@ bool ARMGlobalMerge::doInitialization(Module &M) {
return Changed;
}
-bool ARMGlobalMerge::runOnFunction(Function &F) {
+bool GlobalMerge::runOnFunction(Function &F) {
return false;
}
-FunctionPass *llvm::createARMGlobalMergePass(const TargetLowering *tli) {
- return new ARMGlobalMerge(tli);
+Pass *llvm::createGlobalMergePass(const TargetLowering *tli) {
+ return new GlobalMerge(tli);
}