summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Value.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r--llvm/lib/IR/Value.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index 38eed76fe45..cf32a66c901 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -648,10 +648,14 @@ unsigned Value::getPointerAlignment(const DataLayout &DL) const {
unsigned Align = 0;
if (auto *GO = dyn_cast<GlobalObject>(this)) {
- // Don't make any assumptions about function pointer alignment. Some
- // targets use the LSBs to store additional information.
- if (isa<Function>(GO))
- return 0;
+ if (isa<Function>(GO)) {
+ switch (DL.getFunctionPtrAlignType()) {
+ case DataLayout::FunctionPtrAlignType::Independent:
+ return DL.getFunctionPtrAlign();
+ case DataLayout::FunctionPtrAlignType::MultipleOfFunctionAlign:
+ return std::max(DL.getFunctionPtrAlign(), GO->getAlignment());
+ }
+ }
Align = GO->getAlignment();
if (Align == 0) {
if (auto *GVar = dyn_cast<GlobalVariable>(GO)) {
OpenPOWER on IntegriCloud