diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2012-05-10 23:17:35 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2012-05-10 23:17:35 +0000 |
commit | 9d236f909cec671ef2ff186c8fce6d2e1540a0a9 (patch) | |
tree | 49729dbb18282aae564c029b4effaf97f90f7b01 /lib/Transforms/InstCombine/InstCombineAddSub.cpp | |
parent | deaa3f3e523183b611249bba636876cb05c5881a (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156585 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineAddSub.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineAddSub.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/lib/Transforms/InstCombine/InstCombineAddSub.cpp index 6a39fc33d4..8420a6a96e 100644 --- a/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/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(); |