summaryrefslogtreecommitdiffstats
path: root/unittests/VMCore
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2010-09-17 15:48:55 +0000
committerdim <dim@FreeBSD.org>2010-09-17 15:48:55 +0000
commit5d5cc59cc77afe655b3707cb0e69e0827b444cad (patch)
tree36453626c792cccd91f783a38a169d610a6b9db9 /unittests/VMCore
parent786a18553586229ad99ecb5ecde8a9d914c45e27 (diff)
downloadFreeBSD-src-5d5cc59cc77afe655b3707cb0e69e0827b444cad.zip
FreeBSD-src-5d5cc59cc77afe655b3707cb0e69e0827b444cad.tar.gz
Vendor import of llvm r114020 (from the release_28 branch):
http://llvm.org/svn/llvm-project/llvm/branches/release_28@114020 Approved by: rpaulo (mentor)
Diffstat (limited to 'unittests/VMCore')
-rw-r--r--unittests/VMCore/DerivedTypesTest.cpp57
-rw-r--r--unittests/VMCore/InstructionsTest.cpp4
-rw-r--r--unittests/VMCore/MetadataTest.cpp7
-rw-r--r--unittests/VMCore/PassManagerTest.cpp12
4 files changed, 68 insertions, 12 deletions
diff --git a/unittests/VMCore/DerivedTypesTest.cpp b/unittests/VMCore/DerivedTypesTest.cpp
index 2e0450d..9dea6ff 100644
--- a/unittests/VMCore/DerivedTypesTest.cpp
+++ b/unittests/VMCore/DerivedTypesTest.cpp
@@ -9,13 +9,66 @@
#include "gtest/gtest.h"
#include "../lib/VMCore/LLVMContextImpl.h"
-#include "llvm/Type.h"
#include "llvm/DerivedTypes.h"
#include "llvm/LLVMContext.h"
+#include "llvm/Constants.h"
+#include "llvm/Support/ValueHandle.h"
using namespace llvm;
namespace {
+static void PR7658() {
+ LLVMContext ctx;
+
+ WeakVH NullPtr;
+ PATypeHolder h1;
+ {
+ OpaqueType *o1 = OpaqueType::get(ctx);
+ PointerType *p1 = PointerType::get(o1, 0);
+
+ std::vector<const Type *> t1;
+ t1.push_back(IntegerType::get(ctx, 32));
+ t1.push_back(p1);
+ NullPtr = ConstantPointerNull::get(p1);
+ OpaqueType *o2 = OpaqueType::get (ctx);
+ PointerType *p2 = PointerType::get (o2, 0);
+ t1.push_back(p2);
+
+
+ StructType *s1 = StructType::get(ctx, t1);
+ h1 = s1;
+ o1->refineAbstractTypeTo(s1);
+ o2->refineAbstractTypeTo(h1.get()); // h1 = { i32, \2*, \2* }
+ }
+
+
+ OpaqueType *o3 = OpaqueType::get(ctx);
+ PointerType *p3 = PointerType::get(o3, 0); // p3 = opaque*
+
+ std::vector<const Type *> t2;
+ t2.push_back(IntegerType::get(ctx, 32));
+ t2.push_back(p3);
+
+ std::vector<Constant *> v2;
+ v2.push_back(ConstantInt::get(IntegerType::get(ctx, 32), 14));
+ v2.push_back(ConstantPointerNull::get(p3));
+
+ OpaqueType *o4 = OpaqueType::get(ctx);
+ {
+ PointerType *p4 = PointerType::get(o4, 0);
+ t2.push_back(p4);
+ v2.push_back(ConstantPointerNull::get(p4));
+ }
+
+ WeakVH CS = ConstantStruct::get(ctx, v2, false); // { i32 14, opaque* null, opaque* null}
+
+ StructType *s2 = StructType::get(ctx, t2);
+ PATypeHolder h2(s2);
+ o3->refineAbstractTypeTo(s2);
+ o4->refineAbstractTypeTo(h2.get());
+}
+
+
TEST(OpaqueTypeTest, RegisterWithContext) {
LLVMContext C;
LLVMContextImpl *pImpl = C.pImpl;
@@ -28,6 +81,8 @@ TEST(OpaqueTypeTest, RegisterWithContext) {
EXPECT_EQ(2u, pImpl->OpaqueTypes.size());
}
EXPECT_EQ(1u, pImpl->OpaqueTypes.size());
+
+ PR7658();
}
} // namespace
diff --git a/unittests/VMCore/InstructionsTest.cpp b/unittests/VMCore/InstructionsTest.cpp
index c1baa74..c9fe2a1 100644
--- a/unittests/VMCore/InstructionsTest.cpp
+++ b/unittests/VMCore/InstructionsTest.cpp
@@ -59,9 +59,9 @@ TEST(InstructionsTest, BranchInst) {
EXPECT_EQ(b0->getNumOperands(), 1U);
EXPECT_NE(b0->op_begin(), b0->op_end());
- EXPECT_EQ(next(b0->op_begin()), b0->op_end());
+ EXPECT_EQ(llvm::next(b0->op_begin()), b0->op_end());
- EXPECT_EQ(next(b0->op_begin()), b0->op_end());
+ EXPECT_EQ(llvm::next(b0->op_begin()), b0->op_end());
const IntegerType* Int1 = IntegerType::get(C, 1);
Constant* One = ConstantInt::get(Int1, 1, true);
diff --git a/unittests/VMCore/MetadataTest.cpp b/unittests/VMCore/MetadataTest.cpp
index 04db486..942b848 100644
--- a/unittests/VMCore/MetadataTest.cpp
+++ b/unittests/VMCore/MetadataTest.cpp
@@ -130,11 +130,12 @@ TEST(NamedMDNodeTest, Search) {
MDNode *n = MDNode::get(Context, &V, 1);
MDNode *n2 = MDNode::get(Context, &V2, 1);
- MDNode *Nodes[2] = { n, n2 };
-
Module M("MyModule", Context);
const char *Name = "llvm.NMD1";
- NamedMDNode *NMD = NamedMDNode::Create(Context, Name, &Nodes[0], 2, &M);
+ NamedMDNode *NMD = M.getOrInsertNamedMetadata(Name);
+ NMD->addOperand(n);
+ NMD->addOperand(n2);
+
std::string Str;
raw_string_ostream oss(Str);
NMD->print(oss);
diff --git a/unittests/VMCore/PassManagerTest.cpp b/unittests/VMCore/PassManagerTest.cpp
index cabfc44..96ee5b4 100644
--- a/unittests/VMCore/PassManagerTest.cpp
+++ b/unittests/VMCore/PassManagerTest.cpp
@@ -40,7 +40,7 @@ namespace llvm {
public:
static char run;
static char ID;
- ModuleNDNM() : ModulePass(&ID) {}
+ ModuleNDNM() : ModulePass(ID) {}
virtual bool runOnModule(Module &M) {
run++;
return false;
@@ -56,7 +56,7 @@ namespace llvm {
public:
static char run;
static char ID;
- ModuleNDM() : ModulePass(&ID) {}
+ ModuleNDM() : ModulePass(ID) {}
virtual bool runOnModule(Module &M) {
run++;
return true;
@@ -70,7 +70,7 @@ namespace llvm {
public:
static char run;
static char ID;
- ModuleNDM2() : ModulePass(&ID) {}
+ ModuleNDM2() : ModulePass(ID) {}
virtual bool runOnModule(Module &M) {
run++;
return true;
@@ -83,7 +83,7 @@ namespace llvm {
public:
static char run;
static char ID;
- ModuleDNM() : ModulePass(&ID) {}
+ ModuleDNM() : ModulePass(ID) {}
virtual bool runOnModule(Module &M) {
EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
run++;
@@ -119,7 +119,7 @@ namespace llvm {
EXPECT_TRUE(finalized);
EXPECT_EQ(run, runc);
}
- PassTestBase() : P(&ID), allocated(0) {
+ PassTestBase() : P(ID), allocated(0) {
initialized = false;
finalized = false;
runc = 0;
@@ -253,7 +253,7 @@ namespace llvm {
struct OnTheFlyTest: public ModulePass {
public:
static char ID;
- OnTheFlyTest() : ModulePass(&ID) {}
+ OnTheFlyTest() : ModulePass(ID) {}
virtual bool runOnModule(Module &M) {
EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
for (Module::iterator I=M.begin(),E=M.end(); I != E; ++I) {
OpenPOWER on IntegriCloud