aboutsummaryrefslogtreecommitdiffstats
path: root/unittests/IR/ValueTest.cpp
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-02-11 20:01:10 -0800
committerStephen Hines <srhines@google.com>2014-02-11 20:01:10 -0800
commitce9904c6ea8fd669978a8eefb854b330eb9828ff (patch)
tree2418ee2e96ea220977c8fb74959192036ab5b133 /unittests/IR/ValueTest.cpp
parentc27b10b198c1d9e9b51f2303994313ec2778edd7 (diff)
parentdbb832b83351cec97b025b61c26536ef50c3181c (diff)
downloadexternal_llvm-ce9904c6ea8fd669978a8eefb854b330eb9828ff.zip
external_llvm-ce9904c6ea8fd669978a8eefb854b330eb9828ff.tar.gz
external_llvm-ce9904c6ea8fd669978a8eefb854b330eb9828ff.tar.bz2
Merge remote-tracking branch 'upstream/release_34' into merge-20140211
Conflicts: lib/Linker/LinkModules.cpp lib/Support/Unix/Signals.inc Change-Id: Ia54f291fa5dc828052d2412736e8495c1282aa64
Diffstat (limited to 'unittests/IR/ValueTest.cpp')
-rw-r--r--unittests/IR/ValueTest.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/unittests/IR/ValueTest.cpp b/unittests/IR/ValueTest.cpp
index 52efb1a..ebe23e8 100644
--- a/unittests/IR/ValueTest.cpp
+++ b/unittests/IR/ValueTest.cpp
@@ -43,4 +43,44 @@ TEST(ValueTest, UsedInBasicBlock) {
EXPECT_TRUE(F->arg_begin()->isUsedInBasicBlock(F->begin()));
}
+TEST(GlobalTest, CreateAddressSpace) {
+ LLVMContext &Ctx = getGlobalContext();
+ OwningPtr<Module> M(new Module("TestModule", Ctx));
+ Type *Int8Ty = Type::getInt8Ty(Ctx);
+ Type *Int32Ty = Type::getInt32Ty(Ctx);
+
+ GlobalVariable *Dummy0
+ = new GlobalVariable(*M,
+ Int32Ty,
+ true,
+ GlobalValue::ExternalLinkage,
+ Constant::getAllOnesValue(Int32Ty),
+ "dummy",
+ 0,
+ GlobalVariable::NotThreadLocal,
+ 1);
+
+ // Make sure the address space isn't dropped when returning this.
+ Constant *Dummy1 = M->getOrInsertGlobal("dummy", Int32Ty);
+ EXPECT_EQ(Dummy0, Dummy1);
+ EXPECT_EQ(1u, Dummy1->getType()->getPointerAddressSpace());
+
+
+ // This one requires a bitcast, but the address space must also stay the same.
+ GlobalVariable *DummyCast0
+ = new GlobalVariable(*M,
+ Int32Ty,
+ true,
+ GlobalValue::ExternalLinkage,
+ Constant::getAllOnesValue(Int32Ty),
+ "dummy_cast",
+ 0,
+ GlobalVariable::NotThreadLocal,
+ 1);
+
+ // Make sure the address space isn't dropped when returning this.
+ Constant *DummyCast1 = M->getOrInsertGlobal("dummy_cast", Int8Ty);
+ EXPECT_EQ(1u, DummyCast1->getType()->getPointerAddressSpace());
+ EXPECT_NE(DummyCast0, DummyCast1) << *DummyCast1;
+}
} // end anonymous namespace