[llvm] a4c3ac2 - ARM: Avoid doing strncmp on libcall name (#165203)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 31 12:58:39 PDT 2025


Author: Matt Arsenault
Date: 2025-10-31T12:58:36-07:00
New Revision: a4c3ac2c09f4510a62efb045e129927c52a4c032

URL: https://github.com/llvm/llvm-project/commit/a4c3ac2c09f4510a62efb045e129927c52a4c032
DIFF: https://github.com/llvm/llvm-project/commit/a4c3ac2c09f4510a62efb045e129927c52a4c032.diff

LOG: ARM: Avoid doing strncmp on libcall name (#165203)

Check if the default implementation is the aeabi impl directly.
If getLibcallName returned null, this would crash.

Added: 
    

Modified: 
    llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp b/llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp
index ebfa593fbe9e6..bf7c962f02efc 100644
--- a/llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp
@@ -47,9 +47,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)
-    return SDValue();
-
+  //
   // Translate RTLIB::Libcall to AEABILibcall. We only do this in order to be
   // able to translate memset to memclr and use the value to index the function
   // name array.
@@ -61,12 +59,21 @@ SDValue ARMSelectionDAGInfo::EmitSpecializedLibcall(
   } AEABILibcall;
   switch (LC) {
   case RTLIB::MEMCPY:
+    if (TLI->getLibcallImpl(LC) != RTLIB::impl___aeabi_memcpy)
+      return SDValue();
+
     AEABILibcall = AEABI_MEMCPY;
     break;
   case RTLIB::MEMMOVE:
+    if (TLI->getLibcallImpl(LC) != RTLIB::impl___aeabi_memmove)
+      return SDValue();
+
     AEABILibcall = AEABI_MEMMOVE;
     break;
   case RTLIB::MEMSET:
+    if (TLI->getLibcallImpl(LC) != RTLIB::impl___aeabi_memset)
+      return SDValue();
+
     AEABILibcall = AEABI_MEMSET;
     if (isNullConstant(Src))
       AEABILibcall = AEABI_MEMCLR;


        


More information about the llvm-commits mailing list