diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 92b7f1a39bc719a7c367ff8fadc1463d8f10dc2e..18de1269e9d5ab865c56c2fbd27f0b0ad6114530 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2035,7 +2035,7 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) { New = new MallocInst(CastElTy, Amt, Name); else New = new AllocaInst(CastElTy, Amt, Name); - InsertNewInstBefore(New, CI); + InsertNewInstBefore(New, *AI); return ReplaceInstUsesWith(CI, New); } }