[llvm-commits] [llvm] r84814 - /llvm/trunk/tools/opt/opt.cpp
Chris Lattner
sabre at nondot.org
Wed Oct 21 17:44:11 PDT 2009
Author: lattner
Date: Wed Oct 21 19:44:10 2009
New Revision: 84814
URL: http://llvm.org/viewvc/llvm-project?rev=84814&view=rev
Log:
Add some command line options for twiddling the default data layout
used by opt when a module doesn't specify one. Patch from Kenneth Uildriks!
Modified:
llvm/trunk/tools/opt/opt.cpp
Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=84814&r1=84813&r2=84814&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Wed Oct 21 19:44:10 2009
@@ -127,6 +127,15 @@
static cl::opt<bool>
AnalyzeOnly("analyze", cl::desc("Only perform analysis, no optimization"));
+static cl::opt<std::string>
+DefaultDataLayout("default-data-layout",
+ cl::desc("data layout string to use if not specified by module"),
+ cl::value_desc("layout-string"), cl::init(""));
+
+static cl::opt<bool>
+NoDefaultDataLayout("no-default-data-layout",
+ cl::desc("no data layout assumptions unless module specifies data layout"));
+
// ---------- Define Printers for module and function passes ------------
namespace {
@@ -388,12 +397,21 @@
PassManager Passes;
// Add an appropriate TargetData instance for this module...
- Passes.add(new TargetData(M.get()));
+ TargetData *TD = 0;
+ const std::string &ModuleDataLayout = M.get()->getDataLayout();
+ if (!ModuleDataLayout.empty())
+ TD = new TargetData(ModuleDataLayout);
+ else if (!NoDefaultDataLayout)
+ TD = new TargetData(DefaultDataLayout);
+
+ if (TD)
+ Passes.add(TD);
FunctionPassManager *FPasses = NULL;
if (OptLevelO1 || OptLevelO2 || OptLevelO3) {
FPasses = new FunctionPassManager(new ExistingModuleProvider(M.get()));
- FPasses->add(new TargetData(M.get()));
+ if (TD)
+ FPasses->add(new TargetData(*TD));
}
// If the -strip-debug command line option was specified, add it. If
More information about the llvm-commits
mailing list