Skip to content

Conversation

@arsenm
Copy link
Contributor

@arsenm arsenm commented Oct 27, 2025

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

Copy link
Contributor Author

arsenm commented Oct 27, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arsenm arsenm marked this pull request as ready for review October 27, 2025 05:45
@llvmbot
Copy link
Member

llvmbot commented Oct 27, 2025

@llvm/pr-subscribers-backend-arm

Author: Matt Arsenault (arsenm)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/165203.diff

1 Files Affected:

  • (modified) llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp (+14-1)
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

Check if the default implementation is the aeabi impl directly.
If getLibcallName returned null, this would crash.
@arsenm arsenm force-pushed the users/arsenm/arm/avoid-doing-string-comparison-libcall-name branch from 6843aba to 446dd8e Compare October 31, 2025 03:28
@arsenm arsenm merged commit a4c3ac2 into main Oct 31, 2025
10 checks passed
@arsenm arsenm deleted the users/arsenm/arm/avoid-doing-string-comparison-libcall-name branch October 31, 2025 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants