summaryrefslogtreecommitdiff
path: root/tools/opt
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2013-04-14 23:35:36 +0000
committerEric Christopher <echristo@gmail.com>2013-04-14 23:35:36 +0000
commitf1216abf7ec0d37152a0aaaad5a238beca65ecb6 (patch)
tree72fd4a6b39480b461fe47d6ffe6b78f9671afc1d /tools/opt
parent199ff9cdd72954c9e716260cd75e4928c6eee623 (diff)
downloadllvm-f1216abf7ec0d37152a0aaaad5a238beca65ecb6.tar.gz
llvm-f1216abf7ec0d37152a0aaaad5a238beca65ecb6.tar.bz2
llvm-f1216abf7ec0d37152a0aaaad5a238beca65ecb6.tar.xz
Revert "Remove some unused triple and data layout."
This reverts commit r179497 and the accompanying commit as it broke random platforms that aren't osx. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179499 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/opt')
-rw-r--r--tools/opt/opt.cpp29
1 files changed, 13 insertions, 16 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index e3aa77d3af..e385d7f577 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -36,7 +36,6 @@
#include "llvm/Support/PassNameParser.h"
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/PrettyStackTrace.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/SystemUtils.h"
@@ -530,8 +529,9 @@ static TargetMachine* GetTargetMachine(Triple TheTriple) {
const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple,
Error);
// Some modules don't specify a triple, and this is okay.
- if (!TheTarget)
+ if (!TheTarget) {
return 0;
+ }
// Package up features to be passed to target/subtarget
std::string FeaturesStr;
@@ -598,12 +598,9 @@ int main(int argc, char **argv) {
}
// If we are supposed to override the target triple, do so now.
- const DataLayout *TD;
- if (!TargetTriple.empty()) {
+ if (!TargetTriple.empty())
M->setTargetTriple(Triple::normalize(TargetTriple));
- TD = GetTargetMachine(Triple(TargetTriple))->getDataLayout();
- }
-
+
// Figure out what stream we are supposed to write to...
OwningPtr<tool_output_file> Out;
if (NoOutput) {
@@ -644,16 +641,16 @@ int main(int argc, char **argv) {
TLI->disableAllFunctions();
Passes.add(TLI);
- // If we don't have a data layout by now go ahead and set it if we can.
- if (!TD) {
- const std::string &ModuleDataLayout = M.get()->getDataLayout();
- if (!ModuleDataLayout.empty())
- TD = new DataLayout(ModuleDataLayout);
- else if (!DefaultDataLayout.empty())
- TD = new DataLayout(DefaultDataLayout);
- }
+ // Add an appropriate DataLayout instance for this module.
+ DataLayout *TD = 0;
+ const std::string &ModuleDataLayout = M.get()->getDataLayout();
+ if (!ModuleDataLayout.empty())
+ TD = new DataLayout(ModuleDataLayout);
+ else if (!DefaultDataLayout.empty())
+ TD = new DataLayout(DefaultDataLayout);
+
if (TD)
- Passes.add(new DataLayout(*TD));
+ Passes.add(TD);
Triple ModuleTriple(M->getTargetTriple());
TargetMachine *Machine = 0;