Turn 'free null' into nothing
authorChris Lattner <sabre@nondot.org>
Sat, 28 Feb 2004 04:57:37 +0000 (04:57 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 28 Feb 2004 04:57:37 +0000 (04:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11940 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 0bf785360e860d85856f088fd62b616cf01f47dd..3054e13dfa62593990545eb1d2daa0ed171593ee 100644 (file)
@@ -2287,6 +2287,14 @@ Instruction *InstCombiner::visitFreeInst(FreeInst &FI) {
       return &FI;
     }
 
+  // If we have 'free null' delete the instruction.  This can happen in stl code
+  // when lots of inlining happens.
+  if (isa<ConstantPointerNull>(Op)) {
+    FI.getParent()->getInstList().erase(&FI);
+    removeFromWorkList(&FI);
+    return 0;  // Don't do anything with FI
+  }
+
   return 0;
 }