@@ -36,6 +36,11 @@ static bool isDereferenceableAndAlignedPointerViaAssumption(
36
36
function_ref<bool (const RetainedKnowledge &RK)> CheckSize,
37
37
const DataLayout &DL, const Instruction *CtxI, AssumptionCache *AC,
38
38
const DominatorTree *DT) {
39
+ // Dereferenceable information from assumptions is only valid if the value
40
+ // cannot be freed between the assumption and use. For now just use the
41
+ // information for values that cannot be freed in the function.
42
+ // TODO: More precisely check if the pointer can be freed between assumption
43
+ // and use.
39
44
if (!CtxI || Ptr->canBeFreed ())
40
45
return false ;
41
46
// / Look through assumes to see if both dereferencability and alignment can
@@ -198,36 +203,6 @@ static bool isDereferenceableAndAlignedPointer(
198
203
Size, DL, CtxI, AC, DT, TLI,
199
204
Visited, MaxDepth);
200
205
201
- // Dereferenceable information from assumptions is only valid if the value
202
- // cannot be freed between the assumption and use. For now just use the
203
- // information for values that cannot be freed in the function.
204
- // TODO: More precisely check if the pointer can be freed between assumption
205
- // and use.
206
- if (CtxI && AC && !V->canBeFreed ()) {
207
- // / Look through assumes to see if both dereferencability and alignment can
208
- // / be proven by an assume if needed.
209
- RetainedKnowledge AlignRK;
210
- RetainedKnowledge DerefRK;
211
- bool IsAligned = V->getPointerAlignment (DL) >= Alignment;
212
- if (getKnowledgeForValue (
213
- V, {Attribute::Dereferenceable, Attribute::Alignment}, *AC,
214
- [&](RetainedKnowledge RK, Instruction *Assume, auto ) {
215
- if (!isValidAssumeForContext (Assume, CtxI, DT))
216
- return false ;
217
- if (RK.AttrKind == Attribute::Alignment)
218
- AlignRK = std::max (AlignRK, RK);
219
- if (RK.AttrKind == Attribute::Dereferenceable)
220
- DerefRK = std::max (DerefRK, RK);
221
- IsAligned |= AlignRK && AlignRK.ArgValue >= Alignment.value ();
222
- if (IsAligned && DerefRK &&
223
- DerefRK.ArgValue >= Size.getZExtValue ())
224
- return true ; // We have found what we needed so we stop looking
225
- return false ; // Other assumes may have better information. so
226
- // keep looking
227
- }))
228
- return true ;
229
- }
230
-
231
206
return isDereferenceableAndAlignedPointerViaAssumption (
232
207
V, Alignment,
233
208
[Size](const RetainedKnowledge &RK) {
0 commit comments