Skip to content

Commit cd66a76

Browse files
arsenmDebadri Basak
authored andcommitted
ARM: Avoid doing strncmp on libcall name (llvm#165203)
Check if the default implementation is the aeabi impl directly. If getLibcallName returned null, this would crash.
1 parent e3be57e commit cd66a76

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ SDValue ARMSelectionDAGInfo::EmitSpecializedLibcall(
4747

4848
// Only use a specialized AEABI function if the default version of this
4949
// Libcall is an AEABI function.
50-
if (std::strncmp(TLI->getLibcallName(LC), "__aeabi", 7) != 0)
51-
return SDValue();
52-
50+
//
5351
// Translate RTLIB::Libcall to AEABILibcall. We only do this in order to be
5452
// able to translate memset to memclr and use the value to index the function
5553
// name array.
@@ -61,12 +59,21 @@ SDValue ARMSelectionDAGInfo::EmitSpecializedLibcall(
6159
} AEABILibcall;
6260
switch (LC) {
6361
case RTLIB::MEMCPY:
62+
if (TLI->getLibcallImpl(LC) != RTLIB::impl___aeabi_memcpy)
63+
return SDValue();
64+
6465
AEABILibcall = AEABI_MEMCPY;
6566
break;
6667
case RTLIB::MEMMOVE:
68+
if (TLI->getLibcallImpl(LC) != RTLIB::impl___aeabi_memmove)
69+
return SDValue();
70+
6771
AEABILibcall = AEABI_MEMMOVE;
6872
break;
6973
case RTLIB::MEMSET:
74+
if (TLI->getLibcallImpl(LC) != RTLIB::impl___aeabi_memset)
75+
return SDValue();
76+
7077
AEABILibcall = AEABI_MEMSET;
7178
if (isNullConstant(Src))
7279
AEABILibcall = AEABI_MEMCLR;

0 commit comments

Comments
 (0)