diff options
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
| -rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 107975df1e7..9aaaacc713c 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,10 @@ 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->getParent() + ? GV->getPointerAlignment(GV->getParent()->getDataLayout()) + : 0; if (GVAlign > 1) { unsigned DstWidth = CI2->getType()->getBitWidth(); |

