Run dead type elimination after dead argument elimination.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105552 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/BugPoint/remove_arguments_test.ll b/test/BugPoint/remove_arguments_test.ll
index 39a1371..cf574d3 100644
--- a/test/BugPoint/remove_arguments_test.ll
+++ b/test/BugPoint/remove_arguments_test.ll
@@ -2,12 +2,16 @@
 ; RUN: llvm-dis remove_arguments_test.ll.tmp-reduced-simplified.bc -o - | FileCheck %s
 
 ; Test to make sure that arguments are removed from the function if they are 
-; unnecessary.
+; unnecessary. And clean up any types that that frees up too.
+
+; CHECK: target triple
+; CHECK-NOT: struct.anon
+%struct.anon = type { i32 }
 
 declare i32 @test2()
 
 ; CHECK: define void @test() {
-define i32 @test(i32 %A, i32 %B, float %C) {
+define i32 @test(i32 %A, %struct.anon* %B, float %C) {
 	call i32 @test2()
 	ret i32 %1
 }
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index 82f7874..c5aa6b4 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -116,13 +116,14 @@
 
   std::vector<const PassInfo*> CleanupPasses;
   CleanupPasses.push_back(getPI(createGlobalDCEPass()));
-  CleanupPasses.push_back(getPI(createDeadTypeEliminationPass()));
 
   if (MayModifySemantics)
     CleanupPasses.push_back(getPI(createDeadArgHackingPass()));
   else
     CleanupPasses.push_back(getPI(createDeadArgEliminationPass()));
 
+  CleanupPasses.push_back(getPI(createDeadTypeEliminationPass()));
+
   Module *New = runPassesOn(M, CleanupPasses);
   if (New == 0) {
     errs() << "Final cleanups failed.  Sorry. :(  Please report a bug!\n";