summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR/DataLayoutTest.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/DataLayoutTest.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/DataLayoutTest.cpp')
-rw-r--r--llvm/unittests/IR/DataLayoutTest.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/llvm/unittests/IR/DataLayoutTest.cpp b/llvm/unittests/IR/DataLayoutTest.cpp
new file mode 100644
index 00000000000..e7ed70b7de5
--- /dev/null
+++ b/llvm/unittests/IR/DataLayoutTest.cpp
@@ -0,0 +1,47 @@
+//===- ConstantRangeTest.cpp - ConstantRange tests ------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/IR/DataLayout.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+
+TEST(DataLayoutTest, FunctionPtrAlign) {
+ EXPECT_EQ(0U, DataLayout("").getFunctionPtrAlign());
+ EXPECT_EQ(1U, DataLayout("Fi8").getFunctionPtrAlign());
+ EXPECT_EQ(2U, DataLayout("Fi16").getFunctionPtrAlign());
+ EXPECT_EQ(4U, DataLayout("Fi32").getFunctionPtrAlign());
+ EXPECT_EQ(8U, DataLayout("Fi64").getFunctionPtrAlign());
+ EXPECT_EQ(1U, DataLayout("Fn8").getFunctionPtrAlign());
+ EXPECT_EQ(2U, DataLayout("Fn16").getFunctionPtrAlign());
+ EXPECT_EQ(4U, DataLayout("Fn32").getFunctionPtrAlign());
+ EXPECT_EQ(8U, DataLayout("Fn64").getFunctionPtrAlign());
+ EXPECT_EQ(DataLayout::FunctionPtrAlignType::Independent, \
+ DataLayout("").getFunctionPtrAlignType());
+ EXPECT_EQ(DataLayout::FunctionPtrAlignType::Independent, \
+ DataLayout("Fi8").getFunctionPtrAlignType());
+ EXPECT_EQ(DataLayout::FunctionPtrAlignType::MultipleOfFunctionAlign, \
+ DataLayout("Fn8").getFunctionPtrAlignType());
+ EXPECT_EQ(DataLayout("Fi8"), DataLayout("Fi8"));
+ EXPECT_NE(DataLayout("Fi8"), DataLayout("Fi16"));
+ EXPECT_NE(DataLayout("Fi8"), DataLayout("Fn8"));
+
+ DataLayout a(""), b("Fi8"), c("Fn8");
+ EXPECT_NE(a, b);
+ EXPECT_NE(a, c);
+ EXPECT_NE(b, c);
+
+ a = b;
+ EXPECT_EQ(a, b);
+ a = c;
+ EXPECT_EQ(a, c);
+}
+
+} // anonymous namespace
OpenPOWER on IntegriCloud