[Attributor] Return uses do not free pointers

If a pointer is returned that does not mean it is freed in the current
(function) scope. We can ignore such uses in AANoFree.
This commit is contained in:
Johannes Doerfert 2020-01-10 14:49:45 -06:00
parent 4c62a35860
commit f95553923f
2 changed files with 4 additions and 2 deletions

View File

@ -1772,6 +1772,8 @@ struct AANoFreeFloating : AANoFreeImpl {
Follow = true;
return true;
}
if (isa<ReturnInst>(UserI))
return true;
// Unknown user.
return false;

View File

@ -334,8 +334,8 @@ if.end:
; BOTH: declare void @unknown_fn(i32* (i32*)*)
;
; BOTH: Function Attrs: noinline nounwind uwtable
; BOTH-NEXT: define i32* @calls_unknown_fn(i32* readnone returned "no-capture-maybe-returned" %r)
; ATTRIBUTOR: define i32* @calls_unknown_fn(i32* readnone returned "no-capture-maybe-returned" %r)
; BOTH-NEXT: define i32* @calls_unknown_fn(i32* nofree readnone returned "no-capture-maybe-returned" %r)
; ATTRIBUTOR: define i32* @calls_unknown_fn(i32* nofree readnone returned "no-capture-maybe-returned" %r)
declare void @unknown_fn(i32* (i32*)*) #0
define i32* @calls_unknown_fn(i32* %r) #0 {