[llvm] 19df7fa - [InstCombine] Erase old alloca in cast of alloca transform

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 12:59:26 PDT 2020


Author: Nikita Popov
Date: 2020-03-31T21:57:39+02:00
New Revision: 19df7fa892d42f6abd503a9dd6705e130dadf1a7

URL: https://github.com/llvm/llvm-project/commit/19df7fa892d42f6abd503a9dd6705e130dadf1a7
DIFF: https://github.com/llvm/llvm-project/commit/19df7fa892d42f6abd503a9dd6705e130dadf1a7.diff

LOG: [InstCombine] Erase old alloca in cast of alloca transform

As we don't return the replaceInstUsesWith() result, we are
responsible for erasing the instruction.

NFC apart from worklist order.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 58f9dcedb15f..12fb8e9e96f5 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -153,6 +153,7 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI,
     // allocation instruction, also pointer typed. Thus, cast to use is BitCast.
     Value *NewCast = Builder.CreateBitCast(New, AI.getType(), "tmpcast");
     replaceInstUsesWith(AI, NewCast);
+    eraseInstFromFunction(AI);
   }
   return replaceInstUsesWith(CI, New);
 }


        


More information about the llvm-commits mailing list