diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-03-26 22:26:35 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-03-26 22:26:35 +0000 |
commit | 23798a973157494f8ae9c7c9503ef1044de4721c (patch) | |
tree | 7fbc6579489e551ab7c1a40f7dedc357b0b7a4ad /llvm/unittests/Transforms/Utils/Cloning.cpp | |
parent | b9aea9383ae69cbfb38a9288a6a5a46f688966e0 (diff) | |
download | bcm5719-llvm-23798a973157494f8ae9c7c9503ef1044de4721c.tar.gz bcm5719-llvm-23798a973157494f8ae9c7c9503ef1044de4721c.zip |
CloneFunction: Clone all attributes, including the CC
Summary:
Tested with a unit test because we don't appear to have any transforms
that use this other than ASan, I think.
Fixes PR17935.
Reviewers: nicholas
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D3194
llvm-svn: 204866
Diffstat (limited to 'llvm/unittests/Transforms/Utils/Cloning.cpp')
-rw-r--r-- | llvm/unittests/Transforms/Utils/Cloning.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/unittests/Transforms/Utils/Cloning.cpp b/llvm/unittests/Transforms/Utils/Cloning.cpp index 6dec807b0c7..fb27dc17353 100644 --- a/llvm/unittests/Transforms/Utils/Cloning.cpp +++ b/llvm/unittests/Transforms/Utils/Cloning.cpp @@ -180,6 +180,29 @@ TEST_F(CloneInstruction, Attributes) { delete F2; } +TEST_F(CloneInstruction, CallingConvention) { + Type *ArgTy1[] = { Type::getInt32PtrTy(context) }; + FunctionType *FT1 = FunctionType::get(Type::getVoidTy(context), ArgTy1, false); + + Function *F1 = Function::Create(FT1, Function::ExternalLinkage); + F1->setCallingConv(CallingConv::Cold); + BasicBlock *BB = BasicBlock::Create(context, "", F1); + IRBuilder<> Builder(BB); + Builder.CreateRetVoid(); + + Function *F2 = Function::Create(FT1, Function::ExternalLinkage); + + SmallVector<ReturnInst*, 4> Returns; + ValueToValueMapTy VMap; + VMap[F1->arg_begin()] = F2->arg_begin(); + + CloneFunctionInto(F2, F1, VMap, false, Returns); + EXPECT_EQ(CallingConv::Cold, F2->getCallingConv()); + + delete F1; + delete F2; +} + class CloneFunc : public ::testing::Test { protected: virtual void SetUp() { |