summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/unittests/IR/WaymarkTest.cpp
diff options
context:
space:
mode:
authorpascal <pascal@openbsd.org>2016-09-03 22:46:54 +0000
committerpascal <pascal@openbsd.org>2016-09-03 22:46:54 +0000
commitb5500b9ca0102f1ccaf32f0e77e96d0739aded9b (patch)
treee1b7ebb5a0231f9e6d8d3f6f719582cebd64dc98 /gnu/llvm/unittests/IR/WaymarkTest.cpp
parentclarify purpose of src/gnu/ directory. (diff)
downloadwireguard-openbsd-b5500b9ca0102f1ccaf32f0e77e96d0739aded9b.tar.xz
wireguard-openbsd-b5500b9ca0102f1ccaf32f0e77e96d0739aded9b.zip
Use the space freed up by sparc and zaurus to import LLVM.
ok hackroom@
Diffstat (limited to 'gnu/llvm/unittests/IR/WaymarkTest.cpp')
-rw-r--r--gnu/llvm/unittests/IR/WaymarkTest.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/gnu/llvm/unittests/IR/WaymarkTest.cpp b/gnu/llvm/unittests/IR/WaymarkTest.cpp
new file mode 100644
index 00000000000..a8924efed3f
--- /dev/null
+++ b/gnu/llvm/unittests/IR/WaymarkTest.cpp
@@ -0,0 +1,58 @@
+//===- llvm/unittest/IR/WaymarkTest.cpp - getUser() unit tests ------------===//
+//
+// 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
+//
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/LLVMContext.h"
+#include "gtest/gtest.h"
+#include <algorithm>
+
+namespace llvm {
+namespace {
+
+Constant *char2constant(char c) {
+ return ConstantInt::get(Type::getInt8Ty(getGlobalContext()), c);
+}
+
+
+TEST(WaymarkTest, NativeArray) {
+ static uint8_t tail[22] = "s02s33s30y2y0s1x0syxS";
+ Value * values[22];
+ std::transform(tail, tail + 22, values, char2constant);
+ FunctionType *FT = FunctionType::get(Type::getVoidTy(getGlobalContext()), true);
+ std::unique_ptr<Function> F(
+ Function::Create(FT, GlobalValue::ExternalLinkage));
+ const CallInst *A = CallInst::Create(F.get(), makeArrayRef(values));
+ ASSERT_NE(A, (const CallInst*)nullptr);
+ ASSERT_EQ(1U + 22, A->getNumOperands());
+ const Use *U = &A->getOperandUse(0);
+ const Use *Ue = &A->getOperandUse(22);
+ for (; U != Ue; ++U)
+ {
+ EXPECT_EQ(A, U->getUser());
+ }
+ delete A;
+}
+
+TEST(WaymarkTest, TwoBit) {
+ Use* many = (Use*)calloc(sizeof(Use), 8212 + 1);
+ ASSERT_TRUE(many);
+ Use::initTags(many, many + 8212);
+ for (Use *U = many, *Ue = many + 8212 - 1; U != Ue; ++U)
+ {
+ EXPECT_EQ(reinterpret_cast<User *>(Ue + 1), U->getUser());
+ }
+ free(many);
+}
+
+} // end anonymous namespace
+} // end namespace llvm