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 | 891835ae0f801da0d25503c0a66a218bf4629c59 (patch) | |
tree | c892af3676d6614addd89a33047cf2000d74b218 /unittests | |
parent | 899a605fc19df8f6b80f2e5e55512d04aee10c5a (diff) | |
download | llvm-891835ae0f801da0d25503c0a66a218bf4629c59.tar.gz llvm-891835ae0f801da0d25503c0a66a218bf4629c59.tar.bz2 llvm-891835ae0f801da0d25503c0a66a218bf4629c59.tar.xz |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204866 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/Transforms/Utils/Cloning.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/unittests/Transforms/Utils/Cloning.cpp b/unittests/Transforms/Utils/Cloning.cpp index 6dec807b0c..fb27dc1735 100644 --- a/unittests/Transforms/Utils/Cloning.cpp +++ b/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() { |