summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-05-06 20:08:20 +0000
committerReid Kleckner <reid@kleckner.net>2014-05-06 20:08:20 +0000
commit39497497016cbe38c3fb4ecfad03506a4ee015dd (patch)
tree901127e680ff62faef59b31b47ddcfd563bd0830 /unittests
parente3e870facee9f1fcf5b19f15a3deb78b582fb37e (diff)
downloadllvm-39497497016cbe38c3fb4ecfad03506a4ee015dd.tar.gz
llvm-39497497016cbe38c3fb4ecfad03506a4ee015dd.tar.bz2
llvm-39497497016cbe38c3fb4ecfad03506a4ee015dd.tar.xz
Copy the full TailCallKind in CallInst::clone_impl
Split from the musttail inliner change. This will be covered by an opt test when the inliner change lands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208126 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/IR/InstructionsTest.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/unittests/IR/InstructionsTest.cpp b/unittests/IR/InstructionsTest.cpp
index e76afa8a77..336f5a2dcd 100644
--- a/unittests/IR/InstructionsTest.cpp
+++ b/unittests/IR/InstructionsTest.cpp
@@ -483,6 +483,39 @@ TEST(InstructionsTest, isEliminableCastPair) {
}
+TEST(InstructionsTest, CloneCall) {
+ LLVMContext &C(getGlobalContext());
+ Type *Int32Ty = Type::getInt32Ty(C);
+ Type *ArgTys[] = {Int32Ty, Int32Ty, Int32Ty};
+ Type *FnTy = FunctionType::get(Int32Ty, ArgTys, /*isVarArg=*/false);
+ Value *Callee = Constant::getNullValue(FnTy->getPointerTo());
+ Value *Args[] = {
+ ConstantInt::get(Int32Ty, 1),
+ ConstantInt::get(Int32Ty, 2),
+ ConstantInt::get(Int32Ty, 3)
+ };
+ std::unique_ptr<CallInst> Call(CallInst::Create(Callee, Args, "result"));
+
+ // Test cloning the tail call kind.
+ CallInst::TailCallKind Kinds[] = {CallInst::TCK_None, CallInst::TCK_Tail,
+ CallInst::TCK_MustTail};
+ for (CallInst::TailCallKind TCK : Kinds) {
+ Call->setTailCallKind(TCK);
+ std::unique_ptr<CallInst> Clone(cast<CallInst>(Call->clone()));
+ EXPECT_EQ(Call->getTailCallKind(), Clone->getTailCallKind());
+ }
+ Call->setTailCallKind(CallInst::TCK_None);
+
+ // Test cloning an attribute.
+ {
+ AttrBuilder AB;
+ AB.addAttribute(Attribute::ReadOnly);
+ Call->setAttributes(AttributeSet::get(C, AttributeSet::FunctionIndex, AB));
+ std::unique_ptr<CallInst> Clone(cast<CallInst>(Call->clone()));
+ EXPECT_TRUE(Clone->onlyReadsMemory());
+ }
+}
+
} // end anonymous namespace
} // end namespace llvm