aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Transforms/Utils/Local.h
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-07-20 23:07:40 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-07-20 23:07:40 +0000
commitc606c3ff911eddcbf8bab95e67c7d8c1f69a493e (patch)
tree419225500a5672a9cb93e01358f2de62a7e5a6f3 /include/llvm/Transforms/Utils/Local.h
parent78435f6bb7574d3d26f8c5151e2c140c525b7994 (diff)
downloadexternal_llvm-c606c3ff911eddcbf8bab95e67c7d8c1f69a493e.zip
external_llvm-c606c3ff911eddcbf8bab95e67c7d8c1f69a493e.tar.gz
external_llvm-c606c3ff911eddcbf8bab95e67c7d8c1f69a493e.tar.bz2
baby steps toward fixing some problems with inbound GEPs that overflow, as discussed 2 months ago or so.
Make sure we do not emit index computations with NSW flags so that we dont get an undef value if the GEP overflows git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160589 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Transforms/Utils/Local.h')
-rw-r--r--include/llvm/Transforms/Utils/Local.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/llvm/Transforms/Utils/Local.h b/include/llvm/Transforms/Utils/Local.h
index 84c0c58..495eab7 100644
--- a/include/llvm/Transforms/Utils/Local.h
+++ b/include/llvm/Transforms/Utils/Local.h
@@ -168,15 +168,18 @@ static inline unsigned getKnownAlignment(Value *V, const TargetData *TD = 0) {
/// 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.
+/// When NoAssumptions is true, no assumptions about index computation not
+/// overflowing is made.
template<typename IRBuilderTy>
-Value *EmitGEPOffset(IRBuilderTy *Builder, const TargetData &TD, User *GEP) {
+Value *EmitGEPOffset(IRBuilderTy *Builder, const TargetData &TD, User *GEP,
+ bool NoAssumptions = false) {
gep_type_iterator GTI = gep_type_begin(GEP);
Type *IntPtrTy = TD.getIntPtrType(GEP->getContext());
Value *Result = Constant::getNullValue(IntPtrTy);
// 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() && !NoAssumptions;
// Build a mask for high order bits.
unsigned IntPtrWidth = TD.getPointerSizeInBits();