summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR/FunctionTest.cpp
diff options
context:
space:
mode:
authorMichael Platings <michael.platings@arm.com>2019-03-07 09:15:23 +0000
committerMichael Platings <michael.platings@arm.com>2019-03-07 09:15:23 +0000
commitfd4156ed4d30828fbcca7b42618dde0550c9b674 (patch)
treefdc8b02c65f61b60fcdd2b7702a1e77badce6b9a /llvm/unittests/IR/FunctionTest.cpp
parentb0f764c73732958745f13e5310131d0e7c3fa400 (diff)
downloadbcm5719-llvm-fd4156ed4d30828fbcca7b42618dde0550c9b674.tar.gz
bcm5719-llvm-fd4156ed4d30828fbcca7b42618dde0550c9b674.zip
[IR][ARM] Add function pointer alignment to datalayout
Use this feature to fix a bug on ARM where 4 byte alignment is incorrectly assumed. Differential Revision: https://reviews.llvm.org/D57335 llvm-svn: 355585
Diffstat (limited to 'llvm/unittests/IR/FunctionTest.cpp')
-rw-r--r--llvm/unittests/IR/FunctionTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/unittests/IR/FunctionTest.cpp b/llvm/unittests/IR/FunctionTest.cpp
index 10a359ff64b..c68b064afe3 100644
--- a/llvm/unittests/IR/FunctionTest.cpp
+++ b/llvm/unittests/IR/FunctionTest.cpp
@@ -129,4 +129,29 @@ TEST(FunctionTest, setSection) {
EXPECT_TRUE(F->hasSection());
}
+TEST(FunctionTest, GetPointerAlignment) {
+ LLVMContext Context;
+ Type *VoidType(Type::getVoidTy(Context));
+ FunctionType *FuncType(FunctionType::get(VoidType, false));
+ Function *Func = Function::Create(
+ FuncType, GlobalValue::ExternalLinkage);
+ EXPECT_EQ(0U, Func->getPointerAlignment(DataLayout("")));
+ EXPECT_EQ(1U, Func->getPointerAlignment(DataLayout("Fi8")));
+ EXPECT_EQ(1U, Func->getPointerAlignment(DataLayout("Fn8")));
+ EXPECT_EQ(2U, Func->getPointerAlignment(DataLayout("Fi16")));
+ EXPECT_EQ(2U, Func->getPointerAlignment(DataLayout("Fn16")));
+ EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fi32")));
+ EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fn32")));
+
+ Func->setAlignment(4U);
+
+ EXPECT_EQ(0U, Func->getPointerAlignment(DataLayout("")));
+ EXPECT_EQ(1U, Func->getPointerAlignment(DataLayout("Fi8")));
+ EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fn8")));
+ EXPECT_EQ(2U, Func->getPointerAlignment(DataLayout("Fi16")));
+ EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fn16")));
+ EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fi32")));
+ EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fn32")));
+}
+
} // end namespace
OpenPOWER on IntegriCloud