summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/MDBuilder.cpp
diff options
context:
space:
mode:
authorCharles Davis <cdavis5x@gmail.com>2015-02-25 05:10:25 +0000
committerCharles Davis <cdavis5x@gmail.com>2015-02-25 05:10:25 +0000
commit33d1dc000806708d65597da6a810bb450664f11d (patch)
treec0364e7539f6502c53b407f6cfb9eb1eee325010 /llvm/lib/IR/MDBuilder.cpp
parentd70bb8d8cbe78dceb6d3ac501244874d8f1b85af (diff)
downloadbcm5719-llvm-33d1dc000806708d65597da6a810bb450664f11d.tar.gz
bcm5719-llvm-33d1dc000806708d65597da6a810bb450664f11d.zip
[IC] Turn non-null MD on pointer loads to range MD on integer loads.
Summary: This change fixes the FIXME that you recently added when you committed (a modified version of) my patch. When `InstCombine` combines a load and store of an pointer to those of an equivalently-sized integer, it currently drops any `!nonnull` metadata that might be present. This change replaces `!nonnull` metadata with `!range !{ 1, -1 }` metadata instead. Reviewers: chandlerc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7621 llvm-svn: 230462
Diffstat (limited to 'llvm/lib/IR/MDBuilder.cpp')
-rw-r--r--llvm/lib/IR/MDBuilder.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/IR/MDBuilder.cpp b/llvm/lib/IR/MDBuilder.cpp
index d6d03b48d0f..a9010114044 100644
--- a/llvm/lib/IR/MDBuilder.cpp
+++ b/llvm/lib/IR/MDBuilder.cpp
@@ -55,14 +55,18 @@ MDNode *MDBuilder::createBranchWeights(ArrayRef<uint32_t> Weights) {
MDNode *MDBuilder::createRange(const APInt &Lo, const APInt &Hi) {
assert(Lo.getBitWidth() == Hi.getBitWidth() && "Mismatched bitwidths!");
+
+ Type *Ty = IntegerType::get(Context, Lo.getBitWidth());
+ return createRange(ConstantInt::get(Ty, Lo), ConstantInt::get(Ty, Hi));
+}
+
+MDNode *MDBuilder::createRange(Constant *Lo, Constant *Hi) {
// If the range is everything then it is useless.
if (Hi == Lo)
return nullptr;
// Return the range [Lo, Hi).
- Type *Ty = IntegerType::get(Context, Lo.getBitWidth());
- Metadata *Range[2] = {createConstant(ConstantInt::get(Ty, Lo)),
- createConstant(ConstantInt::get(Ty, Hi))};
+ Metadata *Range[2] = {createConstant(Lo), createConstant(Hi)};
return MDNode::get(Context, Range);
}
OpenPOWER on IntegriCloud