Skip to content

Commit 86fdd93

Browse files
committed
ARM: Avoid doing strncmp on libcall name
Check if the default implementation is the aeabi impl directly. If getLibcallName returned null, this would crash.
1 parent f8b5f86 commit 86fdd93

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ bool ARMSelectionDAGInfo::isTargetMemoryOpcode(unsigned Opcode) const {
3535
Opcode <= ARMISD::LAST_MEMORY_OPCODE;
3636
}
3737

38+
static bool isAEABIFunctionImpl(const TargetLowering &TLI, RTLIB::Libcall LC) {
39+
switch (LC) {
40+
case RTLIB::MEMCPY:
41+
return TLI.getLibcallImpl(LC) == RTLIB::impl___aeabi_memcpy;
42+
case RTLIB::MEMMOVE:
43+
return TLI.getLibcallImpl(LC) == RTLIB::impl___aeabi_memmove;
44+
case RTLIB::MEMSET:
45+
return TLI.getLibcallImpl(LC) == RTLIB::impl___aeabi_memset;
46+
default:
47+
return false;
48+
}
49+
}
50+
3851
// Emit, if possible, a specialized version of the given Libcall. Typically this
3952
// means selecting the appropriately aligned version, but we also convert memset
4053
// of 0 into memclr.
@@ -47,7 +60,7 @@ SDValue ARMSelectionDAGInfo::EmitSpecializedLibcall(
4760

4861
// Only use a specialized AEABI function if the default version of this
4962
// Libcall is an AEABI function.
50-
if (std::strncmp(TLI->getLibcallName(LC), "__aeabi", 7) != 0)
63+
if (!isAEABIFunctionImpl(*TLI, LC))
5164
return SDValue();
5265

5366
// Translate RTLIB::Libcall to AEABILibcall. We only do this in order to be

0 commit comments

Comments
 (0)