diff options
author | Guillaume Chatelet <gchatelet@google.com> | 2019-10-15 11:24:36 +0000 |
---|---|---|
committer | Guillaume Chatelet <gchatelet@google.com> | 2019-10-15 11:24:36 +0000 |
commit | 0e62011df891d0e7ad904524edf705d07d12d5d4 (patch) | |
tree | 382bb15747d33686e71e748a0a5508997f006803 /llvm/unittests/IR/ConstantsTest.cpp | |
parent | 284827f32bd8d06ca1ab8a949bf96088612b1504 (diff) | |
download | bcm5719-llvm-0e62011df891d0e7ad904524edf705d07d12d5d4.tar.gz bcm5719-llvm-0e62011df891d0e7ad904524edf705d07d12d5d4.zip |
[Alignment][NFC] Remove dependency on GlobalObject::setAlignment(unsigned)
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
Reviewers: courbet
Subscribers: arsenm, mehdi_amini, jvesely, nhaehnle, hiraditya, steven_wu, dexonsmith, dang, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68944
llvm-svn: 374880
Diffstat (limited to 'llvm/unittests/IR/ConstantsTest.cpp')
-rw-r--r-- | llvm/unittests/IR/ConstantsTest.cpp | 14 |
1 files changed, 8 insertions, 6 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)); |