From 9c3b55ea9f5fe17c5713757e97aa62e0fb356dcf Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 24 Apr 2003 19:13:02 +0000 Subject: [PATCH] Make sure to create a target data that matches the Module's target properties. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5904 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/analyze/analyze.cpp | 4 ++++ tools/bugpoint/OptimizerDriver.cpp | 3 +++ tools/gccas/gccas.cpp | 5 ++++- tools/gccld/gccld.cpp | 4 ++++ tools/opt/opt.cpp | 3 +++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp index 83cfda2354a..1119fccfa33 100644 --- a/tools/analyze/analyze.cpp +++ b/tools/analyze/analyze.cpp @@ -15,6 +15,7 @@ #include "llvm/Bytecode/Reader.h" #include "llvm/Assembly/Parser.h" #include "llvm/Analysis/Verifier.h" +#include "llvm/Target/TargetData.h" #include "llvm/Support/PassNameParser.h" #include "Support/Timer.h" #include @@ -126,6 +127,9 @@ int main(int argc, char **argv) { // PassManager Passes; + // Add an appropriate TargetData instance for this module... + Passes.add(new TargetData("analyze", CurMod)); + // Make sure the input LLVM is well formed. Passes.add(createVerifierPass()); diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index 7c6e7c0a793..fefca737951 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -74,6 +74,9 @@ static void RunChild(Module *Program,const std::vector &Passes, } PassManager PM; + // Make sure that the appropriate target data is always used... + PM.add(new TargetData("bugpoint", Program)); + for (unsigned i = 0, e = Passes.size(); i != e; ++i) { if (Passes[i]->getNormalCtor()) PM.add(Passes[i]->getNormalCtor()()); diff --git a/tools/gccas/gccas.cpp b/tools/gccas/gccas.cpp index 043b0d2a823..273e071ad2a 100644 --- a/tools/gccas/gccas.cpp +++ b/tools/gccas/gccas.cpp @@ -66,8 +66,8 @@ void AddConfiguredTransformationPasses(PassManager &PM) { addPass(PM, createGlobalDCEPass()); // Kill unused uinit g-vars addPass(PM, createDeadTypeEliminationPass()); // Eliminate dead types addPass(PM, createConstantMergePass()); // Merge dup global constants - addPass(PM, createVerifierPass()); // Verify that input is correct addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs + addPass(PM, createVerifierPass()); // Verify that input is correct addPass(PM, createDeadInstEliminationPass()); // Remove Dead code/vars addPass(PM, createRaiseAllocationsPass()); // call %malloc -> malloc inst addPass(PM, createIndVarSimplifyPass()); // Simplify indvars @@ -145,6 +145,9 @@ int main(int argc, char **argv) { // PassManager Passes; + // Add an appropriate TargetData instance for this module... + Passes.add(new TargetData("gccas", M.get())); + // Add all of the transformation passes to the pass manager to do the cleanup // and optimization of the GCC output. // diff --git a/tools/gccld/gccld.cpp b/tools/gccld/gccld.cpp index 1d61d13a63f..24c624ece2c 100644 --- a/tools/gccld/gccld.cpp +++ b/tools/gccld/gccld.cpp @@ -18,6 +18,7 @@ #include "llvm/PassManager.h" #include "llvm/Bytecode/Reader.h" #include "llvm/Bytecode/WriteBytecodePass.h" +#include "llvm/Target/TargetData.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" #include "Support/CommandLine.h" @@ -326,6 +327,9 @@ int main(int argc, char **argv) { // PassManager Passes; + // Add an appropriate TargetData instance for this module... + Passes.add(new TargetData("gccas", Composite.get())); + // Linking modules together can lead to duplicated global constants, only keep // one copy of each constant... // diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index d03a65040bb..0127c53480f 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -113,6 +113,9 @@ int main(int argc, char **argv) { // PassManager Passes; + // Add an appropriate TargetData instance for this module... + Passes.add(new TargetData("opt", M.get())); + // Create a new optimization pass for each one specified on the command line for (unsigned i = 0; i < OptimizationList.size(); ++i) { const PassInfo *Opt = OptimizationList[i];