diff options
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r-- | llvm/lib/IR/Value.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index 38eed76fe45..28263ede39d 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -648,10 +648,16 @@ 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()); + default: + llvm_unreachable("unknown function pointer align type"); + } + } Align = GO->getAlignment(); if (Align == 0) { if (auto *GVar = dyn_cast<GlobalVariable>(GO)) { |