[llvm] ARM: Avoid doing strncmp on libcall name (PR #165203)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 26 22:45:04 PDT 2025
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/165203
Check if the default implementation is the aeabi impl directly.
If getLibcallName returned null, this would crash.
>From 6843aba32b5ef53b394969e8553203c2c984b06f Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Sun, 26 Oct 2025 22:25:01 -0700
Subject: [PATCH] ARM: Avoid doing strncmp on libcall name
Check if the default implementation is the aeabi impl directly.
If getLibcallName returned null, this would crash.
---
llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp b/llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp
index ebfa593fbe9e6..d921c8b47c6cb 100644
--- a/llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp
@@ -35,6 +35,19 @@ bool ARMSelectionDAGInfo::isTargetMemoryOpcode(unsigned Opcode) const {
Opcode <= ARMISD::LAST_MEMORY_OPCODE;
}
+static bool isAEABIFunctionImpl(const TargetLowering &TLI, RTLIB::Libcall LC) {
+ switch (LC) {
+ case RTLIB::MEMCPY:
+ return TLI.getLibcallImpl(LC) == RTLIB::impl___aeabi_memcpy;
+ case RTLIB::MEMMOVE:
+ return TLI.getLibcallImpl(LC) == RTLIB::impl___aeabi_memmove;
+ case RTLIB::MEMSET:
+ return TLI.getLibcallImpl(LC) == RTLIB::impl___aeabi_memset;
+ default:
+ return false;
+ }
+}
+
// Emit, if possible, a specialized version of the given Libcall. Typically this
// means selecting the appropriately aligned version, but we also convert memset
// of 0 into memclr.
@@ -47,7 +60,7 @@ SDValue ARMSelectionDAGInfo::EmitSpecializedLibcall(
// Only use a specialized AEABI function if the default version of this
// Libcall is an AEABI function.
- if (std::strncmp(TLI->getLibcallName(LC), "__aeabi", 7) != 0)
+ if (!isAEABIFunctionImpl(*TLI, LC))
return SDValue();
// Translate RTLIB::Libcall to AEABILibcall. We only do this in order to be
More information about the llvm-commits
mailing list