[llvm] Hexagon: Add runtime libcall entries for volatile memcpy call (PR #156561)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 2 18:10:07 PDT 2025
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/156561
This pass currently doesn't have TargetLoweringInfo, but technically
it should verify the call is available from a future RuntimeLibcallsInfo
analysis.
>From d14d84075881ca24bf5890fa5eed31d1ea28b630 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Wed, 6 Aug 2025 11:45:49 +0900
Subject: [PATCH] Hexagon: Add runtime libcall entries for volatile memcpy call
This pass currently doesn't have TargetLoweringInfo, but technically
it should verify the call is available from a future RuntimeLibcallsInfo
analysis.
---
llvm/include/llvm/IR/RuntimeLibcalls.td | 3 +++
llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index 24ea92cc6865d..c909ec6c660b7 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -446,6 +446,7 @@ def AEABI_MEMCLR8 : RuntimeLibcall;
// Hexagon calls
def HEXAGON_MEMCPY_LIKELY_ALIGNED_MIN32BYTES_MULT8BYTES : RuntimeLibcall;
+def HEXAGON_VOLATILE_MEMCPY : RuntimeLibcall;
// XCore calls
def MEMCPY_ALIGN_4 : RuntimeLibcall;
@@ -1875,6 +1876,8 @@ def __hexagon_fast2_sqrtdf2 : RuntimeLibcallImpl<FAST_SQRT_F64>;
def __hexagon_memcpy_likely_aligned_min32bytes_mult8bytes
: RuntimeLibcallImpl<HEXAGON_MEMCPY_LIKELY_ALIGNED_MIN32BYTES_MULT8BYTES>;
+
+def hexagon_memcpy_forward_vp4cp4n2 : RuntimeLibcallImpl<HEXAGON_VOLATILE_MEMCPY>;
}
def isHexagon : RuntimeLibcallPredicate<"TT.getArch() == Triple::hexagon">;
diff --git a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
index 72575f2560a34..c6e643f9ea40f 100644
--- a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
@@ -42,6 +42,7 @@
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/PatternMatch.h"
+#include "llvm/IR/RuntimeLibcalls.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
@@ -2246,6 +2247,11 @@ bool HexagonLoopIdiomRecognize::processCopyingStore(Loop *CurLoop,
Type *PtrTy = PointerType::get(Ctx, 0);
Type *VoidTy = Type::getVoidTy(Ctx);
Module *M = Func->getParent();
+
+ // FIXME: This should check if the call is supported
+ StringRef HexagonVolatileMemcpyName =
+ RuntimeLibcallsInfo::getLibcallImplName(
+ RTLIB::impl_hexagon_memcpy_forward_vp4cp4n2);
FunctionCallee Fn = M->getOrInsertFunction(
HexagonVolatileMemcpyName, VoidTy, PtrTy, PtrTy, Int32Ty);
More information about the llvm-commits
mailing list