diff options
| author | Artur Pilipenko <apilipenko@azulsystems.com> | 2015-11-02 17:53:51 +0000 |
|---|---|---|
| committer | Artur Pilipenko <apilipenko@azulsystems.com> | 2015-11-02 17:53:51 +0000 |
| commit | 5c5011d503fa8c2d225f947adec3bda6141b91c5 (patch) | |
| tree | 8960d95cb25d67ab261f4952230cf04e1168ac9f /llvm/lib/IR | |
| parent | 5daa9b231f5ba14ee8dd902260c8edae13cc01de (diff) | |
| download | bcm5719-llvm-5c5011d503fa8c2d225f947adec3bda6141b91c5.tar.gz bcm5719-llvm-5c5011d503fa8c2d225f947adec3bda6141b91c5.zip | |
Preserve load alignment and dereferenceable metadata during some transformations
Reviewed By: hfinkel
Differential Revision: http://reviews.llvm.org/D13953
llvm-svn: 251809
Diffstat (limited to 'llvm/lib/IR')
| -rw-r--r-- | llvm/lib/IR/Metadata.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index 7d8c3523743..80f18daa79b 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -953,6 +953,17 @@ MDNode *MDNode::getMostGenericRange(MDNode *A, MDNode *B) { return MDNode::get(A->getContext(), MDs); } +MDNode *MDNode::getMostGenericAlignmentOrDereferenceable(MDNode *A, MDNode *B) { + if (!A || !B) + return nullptr; + + ConstantInt *AVal = mdconst::extract<ConstantInt>(A->getOperand(0)); + ConstantInt *BVal = mdconst::extract<ConstantInt>(B->getOperand(0)); + if (AVal->getZExtValue() < BVal->getZExtValue()) + return A; + return B; +} + //===----------------------------------------------------------------------===// // NamedMDNode implementation. // |

