[PATCH] D92569: [AArch64] Lower calls with rv_marker attribute .
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 4 07:55:41 PST 2020
fhahn added a comment.
In D92569#2433647 <https://reviews.llvm.org/D92569#2433647>, @dmgreen wrote:
>> Together with the front- & middle-end changes, this should address PR31925 for AArch64.
>
> This one: https://bugs.llvm.org/show_bug.cgi?id=31925 ? I was looking for more context but didn't find it.
Yes it's the right bug, but unfortunately does not have too much helpful information. Some more details about this optimization can be found here: https://opensource.apple.com/source/objc4/objc4-493.9/runtime/objc-arr.mm (search for `Fast handling of returned autoreleased values`).
I'll try to summarize the optimization. The goal is to reduce the overhead of `objc_autoreleaseReturnValue ` in `Callee` followed by `objc_retainAutoreleasedReturnValue` in `Caller` in the snippet below. If they are back-to-back, then the `ret` object does not have to be added to the autorelease pool and which is much quicker.
To detect that pattern, `objc_autoreleaseReturnValue` looks at the instruction after `ret = callee()` in `Caller`. If it is the special marker instruction (`mov x29, x29` on AArch64), then it assumes that it can do the optimization. The compiler is responsible for inserting this special marker. Currently it injects the marker as inline assembly (https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp#L483), but optimizations can move things in between he call and the marker. This patch ensures that nothing can move instructions between the call and the marker in the backend. @ahatanak will soon post a patch for the front- and middle-end.
Caller:
ret = callee();
objc_retainAutoreleasedReturnValue(ret);
// use ret here
Callee:
// compute ret
[ret retain];
return objc_autoreleaseReturnValue(ret);
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92569/new/
https://reviews.llvm.org/D92569
More information about the llvm-commits
mailing list