summaryrefslogtreecommitdiff
path: root/unittests
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
commit2b9c136346f921b82ae70aaf12ee53a4e6f7725a (patch)
tree86feb00f323cd046490cb2fac6dcc271e0a874f8 /unittests
parent1e0d415c13ed8a4fee0c49c47e5369020ab37049 (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269110 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Transforms/Utils/Cloning.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/unittests/Transforms/Utils/Cloning.cpp b/unittests/Transforms/Utils/Cloning.cpp
index 44804107738..f53e0a95e94 100644
--- a/unittests/Transforms/Utils/Cloning.cpp
+++ b/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