2013-01-07 15:35:46 +00:00
|
|
|
//===- llvm/unittest/IR/WaymarkTest.cpp - getUser() unit tests ------------===//
|
2012-11-12 10:01:17 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// we perform white-box tests
|
|
|
|
//
|
Revert patches to add case-range support for PR1255.
The work on this project was left in an unfinished and inconsistent state.
Hopefully someone will eventually get a chance to implement this feature, but
in the meantime, it is better to put things back the way the were. I have
left support in the bitcode reader to handle the case-range bitcode format,
so that we do not lose bitcode compatibility with the llvm 3.3 release.
This reverts the following commits: 155464, 156374, 156377, 156613, 156704,
156757, 156804 156808, 156985, 157046, 157112, 157183, 157315, 157384, 157575,
157576, 157586, 157612, 157810, 157814, 157815, 157880, 157881, 157882, 157884,
157887, 157901, 158979, 157987, 157989, 158986, 158997, 159076, 159101, 159100,
159200, 159201, 159207, 159527, 159532, 159540, 159583, 159618, 159658, 159659,
159660, 159661, 159703, 159704, 160076, 167356, 172025, 186736
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190328 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-09 19:14:35 +00:00
|
|
|
#include "llvm/IR/Constants.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/Function.h"
|
|
|
|
#include "llvm/IR/Instructions.h"
|
|
|
|
#include "llvm/IR/LLVMContext.h"
|
2012-11-12 10:01:17 +00:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
TEST(WaymarkTest, NativeArray) {
|
2016-04-14 21:59:01 +00:00
|
|
|
LLVMContext Context;
|
2012-11-12 10:01:17 +00:00
|
|
|
static uint8_t tail[22] = "s02s33s30y2y0s1x0syxS";
|
|
|
|
Value * values[22];
|
2016-04-14 21:59:01 +00:00
|
|
|
std::transform(tail, tail + 22, values, [&](char c) {
|
|
|
|
return ConstantInt::get(Type::getInt8Ty(Context), c);
|
|
|
|
});
|
|
|
|
FunctionType *FT = FunctionType::get(Type::getVoidTy(Context), true);
|
2014-12-23 17:20:23 +00:00
|
|
|
std::unique_ptr<Function> F(
|
|
|
|
Function::Create(FT, GlobalValue::ExternalLinkage));
|
|
|
|
const CallInst *A = CallInst::Create(F.get(), makeArrayRef(values));
|
2014-06-08 22:29:17 +00:00
|
|
|
ASSERT_NE(A, (const CallInst*)nullptr);
|
2012-11-12 10:01:17 +00:00
|
|
|
ASSERT_EQ(1U + 22, A->getNumOperands());
|
2013-01-23 08:30:21 +00:00
|
|
|
const Use *U = &A->getOperandUse(0);
|
|
|
|
const Use *Ue = &A->getOperandUse(22);
|
2012-11-12 10:01:17 +00:00
|
|
|
for (; U != Ue; ++U)
|
|
|
|
{
|
2012-11-12 13:34:59 +00:00
|
|
|
EXPECT_EQ(A, U->getUser());
|
2012-11-12 10:01:17 +00:00
|
|
|
}
|
2013-01-23 08:33:05 +00:00
|
|
|
delete A;
|
2012-11-12 10:01:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(WaymarkTest, TwoBit) {
|
2012-11-12 13:34:59 +00:00
|
|
|
Use* many = (Use*)calloc(sizeof(Use), 8212 + 1);
|
2012-11-12 10:01:17 +00:00
|
|
|
ASSERT_TRUE(many);
|
2013-01-23 08:30:21 +00:00
|
|
|
Use::initTags(many, many + 8212);
|
2013-01-14 21:23:37 +00:00
|
|
|
for (Use *U = many, *Ue = many + 8212 - 1; U != Ue; ++U)
|
2012-11-12 10:01:17 +00:00
|
|
|
{
|
2013-01-14 21:23:37 +00:00
|
|
|
EXPECT_EQ(reinterpret_cast<User *>(Ue + 1), U->getUser());
|
2012-11-12 10:01:17 +00:00
|
|
|
}
|
2013-01-23 08:33:05 +00:00
|
|
|
free(many);
|
2012-11-12 10:01:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // end anonymous namespace
|
|
|
|
} // end namespace llvm
|