If changing a parent, don't add then remove the object from the leak detector

llvm-svn: 11106
diff --git a/llvm/lib/VMCore/Instruction.cpp b/llvm/lib/VMCore/Instruction.cpp
index 6f2480b..b009c01 100644
--- a/llvm/lib/VMCore/Instruction.cpp
+++ b/llvm/lib/VMCore/Instruction.cpp
@@ -35,13 +35,13 @@
 }
 
 void Instruction::setParent(BasicBlock *P) {
-  if (getParent())
-    LeakDetector::addGarbageObject(this);
+  if (getParent()) {
+    if (!P) LeakDetector::addGarbageObject(this);
+  } else {
+    if (P) LeakDetector::removeGarbageObject(this);
+  }
 
   Parent = P;
-
-  if (getParent())
-    LeakDetector::removeGarbageObject(this);
 }
 
 // Specialize setName to take care of symbol table majik