summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Transforms/Utils/Cloning.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-05-10 20:23:24 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-05-10 20:23:24 +0000
commitdba995601b626cad16f5f503e3755d9cc19f9aab (patch)
treebc9ce0c3c1aca25b7061432e81e842eab200f041 /llvm/unittests/Transforms/Utils/Cloning.cpp
parent4e6cda2db5d464d814a440b3e44c9d76ba12a00a (diff)
downloadbcm5719-llvm-dba995601b626cad16f5f503e3755d9cc19f9aab.tar.gz
bcm5719-llvm-dba995601b626cad16f5f503e3755d9cc19f9aab.zip
Cloning: Clean up the interface to the CloneFunction function.
Remove the ModuleLevelChanges argument, and the ability to create new subprograms for cloned functions. The latter was added without review in r203662, but it has no in-tree clients (all non-test callers pass false for ModuleLevelChanges [1], so it isn't reachable outside of tests). It also isn't clear that adding a duplicate subprogram to the compile unit is always the right thing to do when cloning a function within a module. If this functionality comes back it should be accompanied with a more concrete use case. Furthermore, all in-tree clients add the returned function to the module. Since that's pretty much the only sensible thing you can do with the function, just do that in CloneFunction. [1] http://llvm-cs.pcc.me.uk/lib/Transforms/Utils/CloneFunction.cpp/rCloneFunction Differential Revision: http://reviews.llvm.org/D18628 llvm-svn: 269110
Diffstat (limited to 'llvm/unittests/Transforms/Utils/Cloning.cpp')
-rw-r--r--llvm/unittests/Transforms/Utils/Cloning.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/llvm/unittests/Transforms/Utils/Cloning.cpp b/llvm/unittests/Transforms/Utils/Cloning.cpp
index 44804107738..f53e0a95e94 100644
--- a/llvm/unittests/Transforms/Utils/Cloning.cpp
+++ b/llvm/unittests/Transforms/Utils/Cloning.cpp
@@ -274,8 +274,7 @@ protected:
void CreateNewFunc() {
ValueToValueMapTy VMap;
- NewFunc = CloneFunction(OldFunc, VMap, true, nullptr);
- M->getFunctionList().push_back(NewFunc);
+ NewFunc = CloneFunction(OldFunc, VMap, nullptr);
}
void SetupFinder() {
@@ -301,16 +300,13 @@ TEST_F(CloneFunc, Subprogram) {
EXPECT_FALSE(verifyModule(*M));
unsigned SubprogramCount = Finder->subprogram_count();
- EXPECT_EQ(2U, SubprogramCount);
+ EXPECT_EQ(1U, SubprogramCount);
auto Iter = Finder->subprograms().begin();
- auto *Sub1 = cast<DISubprogram>(*Iter);
- Iter++;
- auto *Sub2 = cast<DISubprogram>(*Iter);
+ auto *Sub = cast<DISubprogram>(*Iter);
- EXPECT_TRUE(
- (Sub1 == OldFunc->getSubprogram() && Sub2 == NewFunc->getSubprogram()) ||
- (Sub1 == NewFunc->getSubprogram() && Sub2 == OldFunc->getSubprogram()));
+ EXPECT_TRUE(Sub == OldFunc->getSubprogram());
+ EXPECT_TRUE(Sub == NewFunc->getSubprogram());
}
// Test that instructions in the old function still belong to it in the
OpenPOWER on IntegriCloud