Simplify internalize pass. Add test case.
[oota-llvm.git] / lib / Transforms / IPO / PruneEH.cpp
index 529f98e504b4815add6591efcff5ef189ea01ea2..ceb9e3e54e81c3e87cdb4f14611f350a6dc2c009 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     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 file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -43,11 +43,12 @@ namespace {
     bool SimplifyFunction(Function *F);
     void DeleteBasicBlock(BasicBlock *BB);
   };
-
-  char PruneEH::ID = 0;
-  RegisterPass<PruneEH> X("prune-eh", "Remove unused exception handling info");
 }
 
+char PruneEH::ID = 0;
+static RegisterPass<PruneEH>
+X("prune-eh", "Remove unused exception handling info");
+
 Pass *llvm::createPruneEHPass() { return new PruneEH(); }
 
 
@@ -122,16 +123,15 @@ bool PruneEH::runOnSCC(const std::vector<CallGraphNode *> &SCC) {
   // If the SCC doesn't unwind or doesn't throw, note this fact.
   if (!SCCMightUnwind || !SCCMightReturn)
     for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
-      uint16_t NewAttributes = ParamAttr::None;
+      ParameterAttributes NewAttributes = ParamAttr::None;
 
       if (!SCCMightUnwind)
         NewAttributes |= ParamAttr::NoUnwind;
       if (!SCCMightReturn)
         NewAttributes |= ParamAttr::NoReturn;
 
-      const ParamAttrsList *PAL = SCC[i]->getFunction()->getParamAttrs();
-      PAL = ParamAttrsList::includeAttrs(PAL, 0, NewAttributes);
-      SCC[i]->getFunction()->setParamAttrs(PAL);
+      const PAListPtr &PAL = SCC[i]->getFunction()->getParamAttrs();
+      SCC[i]->getFunction()->setParamAttrs(PAL.addAttr(0, NewAttributes));
     }
 
   for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
@@ -156,8 +156,8 @@ bool PruneEH::SimplifyFunction(Function *F) {
       if (II->doesNotThrow()) {
         SmallVector<Value*, 8> Args(II->op_begin()+3, II->op_end());
         // Insert a call instruction before the invoke.
-        CallInst *Call = new CallInst(II->getCalledValue(),
-                                      Args.begin(), Args.end(), "", II);
+        CallInst *Call = CallInst::Create(II->getCalledValue(),
+                                          Args.begin(), Args.end(), "", II);
         Call->takeName(II);
         Call->setCallingConv(II->getCallingConv());
         Call->setParamAttrs(II->getParamAttrs());
@@ -170,7 +170,7 @@ bool PruneEH::SimplifyFunction(Function *F) {
 
         // Insert a branch to the normal destination right before the
         // invoke.
-        new BranchInst(II->getNormalDest(), II);
+        BranchInst::Create(II->getNormalDest(), II);
 
         // Finally, delete the invoke instruction!
         BB->getInstList().pop_back();
@@ -201,8 +201,8 @@ bool PruneEH::SimplifyFunction(Function *F) {
           ++NumUnreach;
           break;
         }
-
   }
+
   return MadeChange;
 }