Add support for partial redefs to the fast register allocator.
[oota-llvm.git] / tools / bugpoint / ExtractFunction.cpp
index 918d6a6a2afb6f9665700079d28c7ba7a05f3db9..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()));
@@ -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";