This patches adds a test for nofree function attributes.
Details
Diff Detail
Event Timeline
I like the tests. One comment and one change request was inlined.
llvm/test/Transforms/FunctionAttrs/nofree.ll | ||
---|---|---|
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) |
Could you also check if there is anything in https://reviews.llvm.org/D49165#change-hksiHW8RDcbA that is missing here?
Could you also check if there is anything in https://reviews.llvm.org/D49165#change-hksiHW8RDcbA that is missing here?
Apparently, I cover all of them.
Assuming this passes right now it looks-good-to-me.
I would have moved it into the Attributor test folder (which doesn't exist yet), but that can be done later.
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.
Make sure ninja check-all works with the test (we got support to derive nofree!) and then commit it please.
But even if I run with --disable-nofree-inference=false, I couldn't get any nofree (even only_return).