summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authorRanjeet Singh <Ranjeet.Singh@arm.com>2018-12-04 00:01:23 +0000
committerRanjeet Singh <Ranjeet.Singh@arm.com>2018-12-04 00:01:23 +0000
commitf5d1b6413f4f9a160e030b1a467be0aee7dbfafc (patch)
tree6c8de6bff82e569ebc92282515968ad097f9d048 /llvm/lib/IR/ConstantFold.cpp
parentd97feef2de78440d77920848a469cf98453833d4 (diff)
downloadbcm5719-llvm-f5d1b6413f4f9a160e030b1a467be0aee7dbfafc.tar.gz
bcm5719-llvm-f5d1b6413f4f9a160e030b1a467be0aee7dbfafc.zip
[IR] Don't assume all functions are 4 byte aligned
In some cases different alignments for function might be used to save space e.g. thumb mode with -Oz will try to use 2 byte function alignment. Similar patch that fixed this in other areas exists here https://reviews.llvm.org/D46110 Differential Revision: https://reviews.llvm.org/D55115 llvm-svn: 348215
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 107975df1e7..d34e383f99f 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -27,6 +27,7 @@
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instructions.h"
+#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Support/ErrorHandling.h"
@@ -1077,10 +1078,8 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
isa<GlobalValue>(CE1->getOperand(0))) {
GlobalValue *GV = cast<GlobalValue>(CE1->getOperand(0));
- // Functions are at least 4-byte aligned.
- unsigned GVAlign = GV->getAlignment();
- if (isa<Function>(GV))
- GVAlign = std::max(GVAlign, 4U);
+ unsigned GVAlign =
+ GV->getPointerAlignment(GV->getParent()->getDataLayout());
if (GVAlign > 1) {
unsigned DstWidth = CI2->getType()->getBitWidth();
OpenPOWER on IntegriCloud