diff options
Diffstat (limited to 'llvm/unittests/IR')
-rw-r--r-- | llvm/unittests/IR/ConstantsTest.cpp | 14 | ||||
-rw-r--r-- | llvm/unittests/IR/FunctionTest.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/IR/ValueTest.cpp | 7 |
3 files changed, 12 insertions, 11 deletions
diff --git a/llvm/unittests/IR/ConstantsTest.cpp b/llvm/unittests/IR/ConstantsTest.cpp index 6c3497a6c84..4a8fcaa48e3 100644 --- a/llvm/unittests/IR/ConstantsTest.cpp +++ b/llvm/unittests/IR/ConstantsTest.cpp @@ -476,13 +476,15 @@ TEST(ConstantsTest, BitcastToGEP) { } bool foldFuncPtrAndConstToNull(LLVMContext &Context, Module *TheModule, - uint64_t AndValue, unsigned FunctionAlign = 0) { + uint64_t AndValue, + MaybeAlign FunctionAlign = llvm::None) { Type *VoidType(Type::getVoidTy(Context)); FunctionType *FuncType(FunctionType::get(VoidType, false)); Function *Func(Function::Create( FuncType, GlobalValue::ExternalLinkage, "", TheModule)); - if (FunctionAlign) Func->setAlignment(FunctionAlign); + if (FunctionAlign) + Func->setAlignment(*FunctionAlign); IntegerType *ConstantIntType(Type::getInt32Ty(Context)); ConstantInt *TheConstant(ConstantInt::get(ConstantIntType, AndValue)); @@ -547,21 +549,21 @@ TEST(ConstantsTest, FoldFunctionAlign4PtrAlignMultiple) { LLVMContext Context; Module TheModule("TestModule", Context); TheModule.setDataLayout("Fn8"); - ASSERT_TRUE(foldFuncPtrAndConstToNull(Context, &TheModule, 2, 4)); + ASSERT_TRUE(foldFuncPtrAndConstToNull(Context, &TheModule, 2, Align(4))); } TEST(ConstantsTest, DontFoldFunctionAlign4PtrAlignIndependent) { LLVMContext Context; Module TheModule("TestModule", Context); TheModule.setDataLayout("Fi8"); - ASSERT_FALSE(foldFuncPtrAndConstToNull(Context, &TheModule, 2, 4)); + ASSERT_FALSE(foldFuncPtrAndConstToNull(Context, &TheModule, 2, Align(4))); } TEST(ConstantsTest, DontFoldFunctionPtrIfNoModule) { LLVMContext Context; // Even though the function is explicitly 4 byte aligned, in the absence of a // DataLayout we can't assume that the function pointer is aligned. - ASSERT_FALSE(foldFuncPtrAndConstToNull(Context, nullptr, 2, 4)); + ASSERT_FALSE(foldFuncPtrAndConstToNull(Context, nullptr, 2, Align(4))); } TEST(ConstantsTest, FoldGlobalVariablePtr) { @@ -572,7 +574,7 @@ TEST(ConstantsTest, FoldGlobalVariablePtr) { std::unique_ptr<GlobalVariable> Global( new GlobalVariable(IntType, true, GlobalValue::ExternalLinkage)); - Global->setAlignment(4); + Global->setAlignment(Align(4)); ConstantInt *TheConstant(ConstantInt::get(IntType, 2)); diff --git a/llvm/unittests/IR/FunctionTest.cpp b/llvm/unittests/IR/FunctionTest.cpp index b5662d2ca99..567304cac6b 100644 --- a/llvm/unittests/IR/FunctionTest.cpp +++ b/llvm/unittests/IR/FunctionTest.cpp @@ -151,7 +151,7 @@ TEST(FunctionTest, GetPointerAlignment) { EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fi32"))); EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fn32"))); - Func->setAlignment(4U); + Func->setAlignment(Align(4)); EXPECT_EQ(0U, Func->getPointerAlignment(DataLayout(""))); EXPECT_EQ(1U, Func->getPointerAlignment(DataLayout("Fi8"))); diff --git a/llvm/unittests/IR/ValueTest.cpp b/llvm/unittests/IR/ValueTest.cpp index f26046304f5..0c42e4632e8 100644 --- a/llvm/unittests/IR/ValueTest.cpp +++ b/llvm/unittests/IR/ValueTest.cpp @@ -61,7 +61,7 @@ TEST(GlobalTest, CreateAddressSpace) { 1); EXPECT_TRUE(Value::MaximumAlignment == 536870912U); - Dummy0->setAlignment(536870912U); + Dummy0->setAlignment(Align(536870912)); EXPECT_EQ(Dummy0->getAlignment(), 536870912U); // Make sure the address space isn't dropped when returning this. @@ -90,6 +90,7 @@ TEST(GlobalTest, CreateAddressSpace) { #ifdef GTEST_HAS_DEATH_TEST #ifndef NDEBUG + TEST(GlobalTest, AlignDeath) { LLVMContext Ctx; std::unique_ptr<Module> M(new Module("TestModule", Ctx)); @@ -99,9 +100,7 @@ TEST(GlobalTest, AlignDeath) { Constant::getAllOnesValue(Int32Ty), "var", nullptr, GlobalVariable::NotThreadLocal, 1); - EXPECT_DEATH(Var->setAlignment(536870913U), - "Alignment is neither 0 nor a power of 2"); - EXPECT_DEATH(Var->setAlignment(1073741824U), + EXPECT_DEATH(Var->setAlignment(Align(1073741824U)), "Alignment is greater than MaximumAlignment"); } #endif |