//===-- llc.cpp - Implement the LLVM Native Code Generator ----------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
//
// This is the llc code generator.
//
std::string IFN = InputFilename;
std::string outputFilename;
int Len = IFN.length();
- if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') {
+ if ((Len > 2) &&
+ IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') {
outputFilename = std::string(IFN.begin(), IFN.end()-3); // s/.bc/.s/
} else {
outputFilename = IFN;
// Allocate target machine. First, check whether the user has
// explicitly specified an architecture to compile for.
- TargetMachine* (*TargetMachineAllocator)(unsigned) = 0;
+ TargetMachine* (*TargetMachineAllocator)(const Module&) = 0;
switch (Arch) {
case x86:
TargetMachineAllocator = allocateX86TargetMachine;
}
break;
}
- std::auto_ptr<TargetMachine> target((*TargetMachineAllocator)(0));
+ std::auto_ptr<TargetMachine> target(TargetMachineAllocator(mod));
assert(target.get() && "Could not allocate target machine!");
TargetMachine &Target = *target.get();
const TargetData &TD = Target.getTargetData();
}
Out = new std::ofstream(OutputFilename.c_str());
- // Make sure that the Out file gets unlink'd from the disk if we get a
+ // Make sure that the Out file gets unlinked from the disk if we get a
// SIGINT
RemoveFileOnSignal(OutputFilename);
} else {
return 1;
}
- // Make sure that the Out file gets unlink'd from the disk if we get a
+ // Make sure that the Out file gets unlinked from the disk if we get a
// SIGINT
RemoveFileOnSignal(OutputFilename);
}