[MIParser] Set RegClassOrRegBank during instruction parsing
[llvm-complete.git] / unittests / IR / WaymarkTest.cpp
blob2f64fe0ae99e73f7d3d22948d8f80d4587cbf090
1 //===- llvm/unittest/IR/WaymarkTest.cpp - getUser() unit tests ------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // we perform white-box tests
11 #include "llvm/IR/Constants.h"
12 #include "llvm/IR/Function.h"
13 #include "llvm/IR/Instructions.h"
14 #include "llvm/IR/LLVMContext.h"
15 #include "gtest/gtest.h"
16 #include <algorithm>
18 namespace llvm {
19 namespace {
21 TEST(WaymarkTest, NativeArray) {
22 LLVMContext Context;
23 static uint8_t tail[22] = "s02s33s30y2y0s1x0syxS";
24 Value * values[22];
25 std::transform(tail, tail + 22, values, [&](char c) {
26 return ConstantInt::get(Type::getInt8Ty(Context), c);
27 });
28 FunctionType *FT = FunctionType::get(Type::getVoidTy(Context), true);
29 std::unique_ptr<Function> F(
30 Function::Create(FT, GlobalValue::ExternalLinkage));
31 const CallInst *A = CallInst::Create(F.get(), makeArrayRef(values));
32 ASSERT_NE(A, (const CallInst*)nullptr);
33 ASSERT_EQ(1U + 22, A->getNumOperands());
34 const Use *U = &A->getOperandUse(0);
35 const Use *Ue = &A->getOperandUse(22);
36 for (; U != Ue; ++U)
38 EXPECT_EQ(A, U->getUser());
40 delete A;
43 TEST(WaymarkTest, TwoBit) {
44 Use* many = (Use*)calloc(sizeof(Use), 8212 + 1);
45 ASSERT_TRUE(many);
46 Use::initTags(many, many + 8212);
47 for (Use *U = many, *Ue = many + 8212 - 1; U != Ue; ++U)
49 EXPECT_EQ(reinterpret_cast<User *>(Ue + 1), U->getUser());
51 free(many);
54 } // end anonymous namespace
55 } // end namespace llvm