[llvm] [BOLT][AArch64] Enabling Inlining for Memcpy for AArch64 in BOLT (PR #154929)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 28 10:12:40 PDT 2025


================
@@ -1866,8 +1866,35 @@ Error InlineMemcpy::runOnFunctions(BinaryContext &BC) {
         const bool IsMemcpy8 = (CalleeSymbol->getName() == "_memcpy8");
         const bool IsTailCall = BC.MIB->isTailCall(Inst);
 
+        // Extract size from preceding instructions (AArch64 only).
----------------
yafet-a wrote:

The ++II is now removed. It isn't needed now that instructions are being handled separately in `findMemcpySizeInBytes()`

The `isAArch64()` check is needed because when memcpy's size comes from a register rather than an immediate, the size extraction returns nullopt. Without this, `createInlineMemcpy()` would crash when dereferencing *KnownSize on the null optional. With the check, we skip inlining and the memcpy call remains un-inlined safely (I've added a test to show this clearer).

I have also kept the check in BinaryPasses as opposed to putting it into `InlineMemcpy()` so as to get a slightly earlier return since we know we can stop proceeding before even having to call `InlineMemcpy`.

https://github.com/llvm/llvm-project/pull/154929


More information about the llvm-commits mailing list