From 107d0a87565ac7f067e38b1f73866959cad6f52f Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 13 Nov 2018 17:54:43 +0000 Subject: [CSP, Cloning] Update DuplicateInstructionsInSplitBetween to use DomTreeUpdater. This patch updates DuplicateInstructionsInSplitBetween to update a DTU instead of applying updates to the DT directly. Given that there only are 2 users, also updated them in this patch to avoid churn. I slightly moved the code in CallSiteSplitting around to reduce the places where we have to pass in DTU. If necessary, I could split those changes in a separate patch. This fixes missing DT updates when dealing with musttail calls in CallSiteSplitting, by using DTU->deleteBB. Reviewers: junbuml, kuhar, NutshellySima, indutny, brzycki Reviewed By: NutshellySima llvm-svn: 346769 --- llvm/unittests/Transforms/Utils/CloningTest.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'llvm/unittests/Transforms/Utils/CloningTest.cpp') diff --git a/llvm/unittests/Transforms/Utils/CloningTest.cpp b/llvm/unittests/Transforms/Utils/CloningTest.cpp index 9a1ad19ebaa..051e3cd6235 100644 --- a/llvm/unittests/Transforms/Utils/CloningTest.cpp +++ b/llvm/unittests/Transforms/Utils/CloningTest.cpp @@ -14,6 +14,7 @@ #include "llvm/IR/Constant.h" #include "llvm/IR/DIBuilder.h" #include "llvm/IR/DebugInfo.h" +#include "llvm/IR/DomTreeUpdater.h" #include "llvm/IR/Function.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/InstIterator.h" @@ -224,9 +225,11 @@ TEST_F(CloneInstruction, DuplicateInstructionsToSplit) { Instruction *SubInst = cast(Builder2.CreateSub(MulInst, V)); Builder2.CreateRetVoid(); + // Dummy DTU. ValueToValueMapTy Mapping; - - auto Split = DuplicateInstructionsInSplitBetween(BB2, BB1, SubInst, Mapping); + DomTreeUpdater DTU(DomTreeUpdater::UpdateStrategy::Lazy); + auto Split = + DuplicateInstructionsInSplitBetween(BB2, BB1, SubInst, Mapping, DTU); EXPECT_TRUE(Split); EXPECT_EQ(Mapping.size(), 2u); @@ -271,9 +274,11 @@ TEST_F(CloneInstruction, DuplicateInstructionsToSplitBlocksEq1) { Instruction *SubInst = cast(Builder2.CreateSub(MulInst, V)); Builder2.CreateBr(BB2); + // Dummy DTU. + DomTreeUpdater DTU(DomTreeUpdater::UpdateStrategy::Lazy); ValueToValueMapTy Mapping; - - auto Split = DuplicateInstructionsInSplitBetween(BB2, BB2, BB2->getTerminator(), Mapping); + auto Split = DuplicateInstructionsInSplitBetween( + BB2, BB2, BB2->getTerminator(), Mapping, DTU); EXPECT_TRUE(Split); EXPECT_EQ(Mapping.size(), 3u); @@ -322,9 +327,11 @@ TEST_F(CloneInstruction, DuplicateInstructionsToSplitBlocksEq2) { Instruction *SubInst = cast(Builder2.CreateSub(MulInst, V)); Builder2.CreateBr(BB2); + // Dummy DTU. + DomTreeUpdater DTU(DomTreeUpdater::UpdateStrategy::Lazy); ValueToValueMapTy Mapping; - - auto Split = DuplicateInstructionsInSplitBetween(BB2, BB2, SubInst, Mapping); + auto Split = + DuplicateInstructionsInSplitBetween(BB2, BB2, SubInst, Mapping, DTU); EXPECT_TRUE(Split); EXPECT_EQ(Mapping.size(), 2u); -- cgit v1.2.3