[DAGCombiner] Expand combining of FP logical ops to sign-setting FP ops
[llvm-core.git] / unittests / ExecutionEngine / Orc / IndirectionUtilsTest.cpp
blobed425449784cbff36d28336b83e40b82b5aba720
1 //===- LazyEmittingLayerTest.cpp - Unit tests for the lazy emitting layer -===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
10 #include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
11 #include "OrcTestCommon.h"
12 #include "llvm/ADT/SmallVector.h"
13 #include "gtest/gtest.h"
15 using namespace llvm;
17 namespace {
19 TEST(IndirectionUtilsTest, MakeStub) {
20 LLVMContext Context;
21 ModuleBuilder MB(Context, "x86_64-apple-macosx10.10", "");
22 Function *F = MB.createFunctionDecl<void(DummyStruct, DummyStruct)>("");
23 AttributeSet FnAttrs = AttributeSet::get(
24 Context, AttrBuilder().addAttribute(Attribute::NoUnwind));
25 AttributeSet RetAttrs; // None
26 AttributeSet ArgAttrs[2] = {
27 AttributeSet::get(Context,
28 AttrBuilder().addAttribute(Attribute::StructRet)),
29 AttributeSet::get(Context, AttrBuilder().addAttribute(Attribute::ByVal)),
31 F->setAttributes(AttributeList::get(Context, FnAttrs, RetAttrs, ArgAttrs));
33 auto ImplPtr = orc::createImplPointer(*F->getType(), *MB.getModule(), "", nullptr);
34 orc::makeStub(*F, *ImplPtr);
36 auto II = F->getEntryBlock().begin();
37 EXPECT_TRUE(isa<LoadInst>(*II)) << "First instruction of stub should be a load.";
38 auto *Call = dyn_cast<CallInst>(std::next(II));
39 EXPECT_TRUE(Call != nullptr) << "Second instruction of stub should be a call.";
40 EXPECT_TRUE(Call->isTailCall()) << "Indirect call from stub should be tail call.";
41 EXPECT_TRUE(Call->hasStructRetAttr())
42 << "makeStub should propagate sret attr on 1st argument.";
43 EXPECT_TRUE(Call->paramHasAttr(1U, Attribute::ByVal))
44 << "makeStub should propagate byval attr on 2nd argument.";