[PATCH] Minor refactoring of GEP handling in isDereferenceablePointer
Sanjoy Das
sanjoy at playingwithpointers.com
Thu May 28 11:14:00 PDT 2015
I'm not sure that this is an NFC change -- I think the previous code will return `false` on the `%1` below while the new code will return `true`.
%struct.A = type { [8 x i8], [5 x i8] }
define i8 @f(%struct.A* %a) {
%1 = getelementptr inbounds %struct.A, %struct.A* %a, i64 0, i32 0, i64 10
%2 = load i8, i8* %1
ret i8 %2
}
Please add a test case that shows this difference.
================
Comment at: lib/Analysis/ValueTracking.cpp:2987
@@ +2986,3 @@
+ uint64_t LoadSize = DL.getTypeStoreSize(Ty);
+ Type* BaseType = Base->getType()->getPointerElementType();
+ if ((Offset + LoadSize).ugt(DL.getTypeAllocSize(BaseType)))
----------------
LLVM style is `Type *`.
================
Comment at: lib/Analysis/ValueTracking.cpp:2989
@@ +2988,3 @@
+ if ((Offset + LoadSize).ugt(DL.getTypeAllocSize(BaseType)))
+ return false;
+
----------------
Can we simplify this to `return (Offset + LoadSize).ule(DL.getTypeAllocSize(BaseType))`?
http://reviews.llvm.org/D9874
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list