Make opt grab the triple from the module and use it to initialize the target machine.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171341 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nadav Rotem
2013-01-01 08:00:32 +00:00
parent 117e4d2e19
commit b338d897f9
3 changed files with 10 additions and 13 deletions

View File

@ -524,16 +524,11 @@ CodeGenOpt::Level GetCodeGenOptLevel() {
}
// Returns the TargetMachine instance or zero if no triple is provided.
static TargetMachine* GetTargetMachine(std::string TripleStr) {
if (TripleStr.empty())
return 0;
// Get the target specific parser.
static TargetMachine* GetTargetMachine(Triple TheTriple) {
std::string Error;
Triple TheTriple(Triple::normalize(TargetTriple));
const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple,
Error);
// Some modules don't specify a triple, and this is okay.
if (!TheTarget) {
return 0;
}
@ -656,7 +651,12 @@ int main(int argc, char **argv) {
if (TD)
Passes.add(TD);
std::auto_ptr<TargetMachine> TM(GetTargetMachine(TargetTriple));
Triple ModuleTriple(M->getTargetTriple());
TargetMachine *Machine = 0;
if (ModuleTriple.getArch())
Machine = GetTargetMachine(Triple(ModuleTriple));
std::auto_ptr<TargetMachine> TM(Machine);
if (TM.get()) {
Passes.add(new TargetTransformInfo(TM->getScalarTargetTransformInfo(),
TM->getVectorTargetTransformInfo()));