[llvm] ARM: Avoid doing strncmp on libcall name (PR #165203)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 26 22:45:43 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-arm
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
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
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/165203
More information about the llvm-commits
mailing list