Add support for partial redefs to the fast register allocator.
[oota-llvm.git] / tools / bugpoint / ExtractFunction.cpp
index df9277c10ffcf6331df5b315487fd3420e1a2d23..eaa2c538d96302793a21afa3d2cfdeacc42842aa 100644 (file)
@@ -73,7 +73,7 @@ Module *BugDriver::deleteInstructionFromProgram(const Instruction *I,
   Instruction *TheInst = RI;              // Got the corresponding instruction!
 
   // If this instruction produces a value, replace any users with null values
-  if (isa<StructType>(TheInst->getType()))
+  if (TheInst->getType()->isStructTy())
     TheInst->replaceAllUsesWith(UndefValue::get(TheInst->getType()));
   else if (TheInst->getType() != Type::getVoidTy(I->getContext()))
     TheInst->replaceAllUsesWith(Constant::getNullValue(TheInst->getType()));
@@ -189,8 +189,8 @@ static Constant *GetTorInit(std::vector<std::pair<Function*, int> > &TorList) {
     Elts.push_back(ConstantInt::get(
           Type::getInt32Ty(TorList[i].first->getContext()), TorList[i].second));
     Elts.push_back(TorList[i].first);
-    ArrayElts.push_back(ConstantStruct::get(
-                                        TorList[i].first->getContext(), Elts));
+    ArrayElts.push_back(ConstantStruct::get(TorList[i].first->getContext(),
+                                            Elts, false));
   }
   return ConstantArray::get(ArrayType::get(ArrayElts[0]->getType(), 
                                            ArrayElts.size()),
@@ -323,8 +323,6 @@ llvm::SplitFunctionsOutOfModule(Module *M,
 Module *BugDriver::ExtractMappedBlocksFromModule(const
                                                  std::vector<BasicBlock*> &BBs,
                                                  Module *M) {
-  char *ExtraArg = NULL;
-
   sys::Path uniqueFilename(OutputPrefix + "-extractblocks");
   std::string ErrMsg;
   if (uniqueFilename.createTemporaryFileOnDisk(true, &ErrMsg)) {
@@ -359,9 +357,8 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
   }
   BlocksToNotExtractFile.close();
 
-  const char *uniqueFN = uniqueFilename.c_str();
-  ExtraArg = (char*)malloc(23 + strlen(uniqueFN));
-  strcat(strcpy(ExtraArg, "--extract-blocks-file="), uniqueFN);
+  std::string uniqueFN = "--extract-blocks-file=" + uniqueFilename.str();
+  const char *ExtraArg = uniqueFN.c_str();
 
   std::vector<const PassInfo*> PI;
   std::vector<BasicBlock *> EmptyBBs; // This parameter is ignored.
@@ -370,7 +367,6 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
 
   if (uniqueFilename.exists())
     uniqueFilename.eraseFromDisk(); // Free disk space
-  free(ExtraArg);
 
   if (Ret == 0) {
     outs() << "*** Basic Block extraction failed, please report a bug!\n";