This patch builds upon D76140 by updating metadata on pointer typed loads in inlined functions, when the load is the return value, and the callsite contains return attributes which can be updated as metadata on the load.
Added test cases show this for nonnull, dereferenceable, dereferenceable_or_null
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Minor comments, otherwise LGTM.
llvm/lib/Transforms/Utils/InlineFunction.cpp | ||
---|---|---|
1189 | Nit: Cheap condition first: UpdateXXX && isa<...> | |
1234–1253 | if (auto *CB = dyn_cast<CallBase>(...)) | |
1244 | Nit: I really hope that'll change, for non-null at least. Though, then we might also want to allow it in the metadata so all will be fine except the comment ;) |
thanks for the review @jdoerfert . Will incorporate these changes and rebase on landed D76140.
llvm/lib/Transforms/Utils/InlineFunction.cpp | ||
---|---|---|
1247 | We'll need to avoid updating dereferenceable, dereferenceable_or_null when these metadata is already present on the load. This will avoid updating the metadata with a different value. In effect, we will have the same behaviour as Attribute::merge, where we avoid changing the attribute value when the call already has the same attribute with a value (see test6 in D76140). Will add analogous test case here. |
For the record, this causes a 0.6-0.8% compile-time regression on the tramp3d-v4 benchmark (there is also a 0.03% code-size improvement, so at least something is happening there codegen-wise). Can't say whether this is because adding the metadata itself has some cost, or because the presence of the metadata makes further optimization more expensive.
Hi, some of our internal tests seems to have started crashing due to this patch.
Here's a bug report with a reduced test: https://bugs.llvm.org/show_bug.cgi?id=45590
Please take a look.
Isn't this just VMap.lookup(V)?