diff options
author | Mitch Phillips <mitchphillips@outlook.com> | 2019-03-06 19:17:18 +0000 |
---|---|---|
committer | Mitch Phillips <mitchphillips@outlook.com> | 2019-03-06 19:17:18 +0000 |
commit | 318028f00f3fe7d90f61a19ee3d8aee98838736e (patch) | |
tree | 10176855adcaabb563ae59c846f6f6987b014263 /llvm/lib/IR/ConstantFold.cpp | |
parent | 8f7cfecfbfe73198f5419f13f0150d7102df97ef (diff) | |
download | bcm5719-llvm-318028f00f3fe7d90f61a19ee3d8aee98838736e.tar.gz bcm5719-llvm-318028f00f3fe7d90f61a19ee3d8aee98838736e.zip |
Revert "[IR][ARM] Add function pointer alignment to datalayout"
This reverts commit 2391bfca97290181ae65796ea6da135d1b6d037b.
This reverts rL355522 (https://reviews.llvm.org/D57335).
Kills buildbots that use '-Werror' with the following error:
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm/lib/IR/Value.cpp:657:7: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]
See buildbots http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/30200/steps/check-llvm%20asan/logs/stdio for more information.
llvm-svn: 355537
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 3784405ecb0..037f120f47d 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -26,7 +26,6 @@ #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,29 +1076,10 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1, isa<GlobalValue>(CE1->getOperand(0))) { GlobalValue *GV = cast<GlobalValue>(CE1->getOperand(0)); - unsigned GVAlign; - - if (Module *TheModule = GV->getParent()) { - GVAlign = GV->getPointerAlignment(TheModule->getDataLayout()); - - // If the function alignment is not specified then assume that it - // is 4. - // This is dangerous; on x86, the alignment of the pointer - // corresponds to the alignment of the function, but might be less - // than 4 if it isn't explicitly specified. - // However, a fix for this behaviour was reverted because it - // increased code size (see https://reviews.llvm.org/D55115) - // FIXME: This code should be deleted once existing targets have - // appropriate defaults - if (GVAlign == 0U && isa<Function>(GV)) - GVAlign = 4U; - } else if (isa<Function>(GV)) { - // Without a datalayout we have to assume the worst case: that the - // function pointer isn't aligned at all. - GVAlign = 0U; - } else { - GVAlign = GV->getAlignment(); - } + // Functions are at least 4-byte aligned. + unsigned GVAlign = GV->getAlignment(); + if (isa<Function>(GV)) + GVAlign = std::max(GVAlign, 4U); if (GVAlign > 1) { unsigned DstWidth = CI2->getType()->getBitWidth(); |