llvm.org GIT mirror llvm / 10f8d2b
If we've specified a triple on the command line then go ahead and use that as the default triple for the module and target data layout. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179497 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Christopher 6 years ago
1 changed file(s) with 16 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
3535 #include "llvm/Support/PassNameParser.h"
3636 #include "llvm/Support/PluginLoader.h"
3737 #include "llvm/Support/PrettyStackTrace.h"
38 #include "llvm/Support/raw_ostream.h"
3839 #include "llvm/Support/Signals.h"
3940 #include "llvm/Support/SourceMgr.h"
4041 #include "llvm/Support/SystemUtils.h"
528529 const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple,
529530 Error);
530531 // Some modules don't specify a triple, and this is okay.
531 if (!TheTarget) {
532 if (!TheTarget)
532533 return 0;
533 }
534534
535535 // Package up features to be passed to target/subtarget
536536 std::string FeaturesStr;
597597 }
598598
599599 // If we are supposed to override the target triple, do so now.
600 if (!TargetTriple.empty())
600 const DataLayout *TD;
601 if (!TargetTriple.empty()) {
601602 M->setTargetTriple(Triple::normalize(TargetTriple));
602
603 TD = GetTargetMachine(Triple(TargetTriple))->getDataLayout();
604 }
605
603606 // Figure out what stream we are supposed to write to...
604607 OwningPtr Out;
605608 if (NoOutput) {
640643 TLI->disableAllFunctions();
641644 Passes.add(TLI);
642645
643 // Add an appropriate DataLayout instance for this module.
644 DataLayout *TD = 0;
645 const std::string &ModuleDataLayout = M.get()->getDataLayout();
646 if (!ModuleDataLayout.empty())
647 TD = new DataLayout(ModuleDataLayout);
648 else if (!DefaultDataLayout.empty())
649 TD = new DataLayout(DefaultDataLayout);
650
646 // If we don't have a data layout by now go ahead and set it if we can.
647 if (!TD) {
648 const std::string &ModuleDataLayout = M.get()->getDataLayout();
649 if (!ModuleDataLayout.empty())
650 TD = new DataLayout(ModuleDataLayout);
651 else if (!DefaultDataLayout.empty())
652 TD = new DataLayout(DefaultDataLayout);
653 }
651654 if (TD)
652 Passes.add(TD);
655 Passes.add(new DataLayout(*TD));
653656
654657 Triple ModuleTriple(M->getTargetTriple());
655658 TargetMachine *Machine = 0;