summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-05-10 23:17:35 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-05-10 23:17:35 +0000
commitf573030391ce1f67e4d656dd941cb86cd91ee9ba (patch)
tree3a4241f1a7e46eee377247982c6b59bc3c7289af /llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
parentd9fc53509e8c0d8abf5aee0d6dbe492bdc8298a3 (diff)
downloadbcm5719-llvm-f573030391ce1f67e4d656dd941cb86cd91ee9ba.tar.gz
bcm5719-llvm-f573030391ce1f67e4d656dd941cb86cd91ee9ba.zip
objectsize: add support for GEPs with non-constant indexes
add an additional parameter to InstCombiner::EmitGEPOffset() to force it to *not* emit operations with NUW flag llvm-svn: 156585
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index 6a39fc33d48..8420a6a96e4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -423,7 +423,8 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) {
/// EmitGEPOffset - Given a getelementptr instruction/constantexpr, emit the
/// code necessary to compute the offset from the base pointer (without adding
/// in the base pointer). Return the result as a signed integer of intptr size.
-Value *InstCombiner::EmitGEPOffset(User *GEP) {
+/// If NoNUW is true, then the NUW flag is not used.
+Value *InstCombiner::EmitGEPOffset(User *GEP, bool NoNUW) {
TargetData &TD = *getTargetData();
gep_type_iterator GTI = gep_type_begin(GEP);
Type *IntPtrTy = TD.getIntPtrType(GEP->getContext());
@@ -431,7 +432,7 @@ Value *InstCombiner::EmitGEPOffset(User *GEP) {
// If the GEP is inbounds, we know that none of the addressing operations will
// overflow in an unsigned sense.
- bool isInBounds = cast<GEPOperator>(GEP)->isInBounds();
+ bool isInBounds = cast<GEPOperator>(GEP)->isInBounds() && !NoNUW;
// Build a mask for high order bits.
unsigned IntPtrWidth = TD.getPointerSizeInBits();
OpenPOWER on IntegriCloud