Added copyright header to all C++ source files.
[oota-llvm.git] / tools / llc / llc.cpp
index 631ac99bd6cdd6e6fcfac9ce7237baf3fac903c4..ed99c1c4080a8e92e83d62f7b5f75e723cd647dd 100644 (file)
@@ -1,4 +1,12 @@
 //===-- 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.
 //
@@ -44,7 +52,8 @@ GetFileNameRoot(const std::string &InputFilename)
   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;
@@ -68,7 +77,7 @@ int main(int argc, char **argv) {
 
   // 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;
@@ -102,7 +111,7 @@ int main(int argc, char **argv) {
     } 
     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();
@@ -127,7 +136,7 @@ int main(int argc, char **argv) {
       }
       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 {
@@ -156,7 +165,7 @@ int main(int argc, char **argv) {
         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);
     }