getLazyIRModule always takes ownership. Make that explicit.
[oota-llvm.git] / lib / Target / Mips / MipsOs16.cpp
index 5f9b60c6608f52016a0c542b33177c439fe757d3..7aae964df538552484cc75e83f402525ce4bf5f2 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#define DEBUG_TYPE "mips-os16"
 #include "MipsOs16.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
+#define DEBUG_TYPE "mips-os16"
+
 
 static cl::opt<std::string> Mips32FunctionMask(
   "mips32-function-mask",
@@ -94,6 +95,7 @@ namespace llvm {
 
 bool MipsOs16::runOnModule(Module &M) {
   bool usingMask = Mips32FunctionMask.length() > 0;
+  bool doneUsingMask = false; // this will make it stop repeating
   DEBUG(dbgs() << "Run on Module MipsOs16 \n" << Mips32FunctionMask << "\n");
   if (usingMask)
     DEBUG(dbgs() << "using mask \n" << Mips32FunctionMask << "\n");
@@ -103,12 +105,22 @@ bool MipsOs16::runOnModule(Module &M) {
     if (F->isDeclaration()) continue;
     DEBUG(dbgs() << "Working on " << F->getName() << "\n");
     if (usingMask) {
-      if ((functionIndex < Mips32FunctionMask.length()) &&
-          (Mips32FunctionMask[functionIndex] == '1')) {
-        DEBUG(dbgs() << "mask forced mips32: " << F->getName() << "\n");
-        F->addFnAttr("nomips16");
+      if (!doneUsingMask) {
+        if (functionIndex == Mips32FunctionMask.length())
+          functionIndex = 0;
+        switch (Mips32FunctionMask[functionIndex]) {
+        case '1':
+          DEBUG(dbgs() << "mask forced mips32: " << F->getName() << "\n");
+          F->addFnAttr("nomips16");
+          break;
+        case '.':
+          doneUsingMask = true;
+          break;
+        default:
+          break;
+        }
+        functionIndex++;
       }
-      functionIndex++;
     }
     else {
       if (needsFP(*F)) {