@@ -93,20 +93,26 @@ static bool isDereferenceableAndAlignedPointer(
93
93
Visited, MaxDepth);
94
94
}
95
95
96
- bool CheckForNonNull, CheckForFreed;
97
- APInt KnownDerefBytes (Size .getBitWidth (),
98
- V->getPointerDereferenceableBytes (DL, CheckForNonNull,
99
- CheckForFreed));
100
- if (KnownDerefBytes.getBoolValue () && KnownDerefBytes.uge (Size ) &&
101
- !CheckForFreed)
102
- if (!CheckForNonNull ||
103
- isKnownNonZero (V, SimplifyQuery (DL, DT, AC, CtxI))) {
104
- // As we recursed through GEPs to get here, we've incrementally checked
105
- // that each step advanced by a multiple of the alignment. If our base is
106
- // properly aligned, then the original offset accessed must also be.
107
- APInt Offset (DL.getTypeStoreSizeInBits (V->getType ()), 0 );
108
- return isAligned (V, Offset, Alignment, DL);
109
- }
96
+ auto IsKnownDeref = [&]() {
97
+ bool CheckForNonNull, CheckForFreed;
98
+ APInt KnownDerefBytes (Size .getBitWidth (),
99
+ V->getPointerDereferenceableBytes (DL, CheckForNonNull,
100
+ CheckForFreed));
101
+ if (!KnownDerefBytes.getBoolValue () || !KnownDerefBytes.uge (Size ) ||
102
+ CheckForFreed)
103
+ return false ;
104
+ if (CheckForNonNull &&
105
+ !isKnownNonZero (V, SimplifyQuery (DL, DT, AC, CtxI)))
106
+ return false ;
107
+ return true ;
108
+ };
109
+ if (IsKnownDeref ()) {
110
+ // As we recursed through GEPs to get here, we've incrementally checked
111
+ // that each step advanced by a multiple of the alignment. If our base is
112
+ // properly aligned, then the original offset accessed must also be.
113
+ APInt Offset (DL.getTypeStoreSizeInBits (V->getType ()), 0 );
114
+ return isAligned (V, Offset, Alignment, DL);
115
+ }
110
116
111
117
// / TODO refactor this function to be able to search independently for
112
118
// / Dereferencability and Alignment requirements.
0 commit comments