This patches adds a test for nofree function attributes.
I like the tests. One comment and one change request was inlined.
|98 ↗||(On Diff #200966)|
I guess one could argue realloc/free/... are just like regular, unknown functions wrt. no-free. I'd keep the tests though. And it opens the question if we should derive "is-freed" at some point ;)
|145 ↗||(On Diff #200966)|
So Chandler raised concerns over this kind of checking in D59903. While I have to admit I haven't fixed all test cases yet, I can see his point. Could you check for the attributes in the printed IR version just before the definition?
It would look similar to this one:
; CHECK: Function Attrs: noinline norecurse nounwind readnone uwtable ; CHECK-NEXT: define double* @ret_undef_arg_undef(i32* readnone %b)
We should (in a later patch probably) think about other attributes that would imply nofree.
I guess one can argue readnone should do the trick. There are other things we could pull if
we make nofree also a parameter attribute. Finally we could think about a selective nofree
annotation at a call site to list arguments that are not freed. We could know that because
of dereferenceability after the call.