[llvm] [PowerPC][AIX] Using milicode for memcmp instead of libcall (PR #147093)
zhijian lin via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 7 07:55:09 PDT 2025
================
@@ -9065,8 +9065,15 @@ bool SelectionDAGBuilder::visitMemCmpBCmpCall(const CallInst &I) {
// memcmp(S1,S2,2) != 0 -> (*(short*)LHS != *(short*)RHS) != 0
// memcmp(S1,S2,4) != 0 -> (*(int*)LHS != *(int*)RHS) != 0
- if (!CSize || !isOnlyUsedInZeroEqualityComparison(&I))
+ if (!CSize || !isOnlyUsedInZeroEqualityComparison(&I)) {
+ const Triple& TheTriple = TM.getTargetTriple();
+ if(TheTriple.isOSAIX()) {
+ if (Function *F = I.getCalledFunction()) {
+ F->setName(TheTriple.isArch32Bit() ? "___memcmp" : "___memcmp64");
----------------
diggerlin wrote:
> This is also mutating the IR, you cannot do that in codegen. It's also mutating the function itself, and not the call target
do you means, we can not change the IR ?
in AIX, the function name will be used to generate an external symbol. and the AIX OS linker and loader will use the external symbol to find the correct function address in the memory , if we change the function name memcmp to function name to "___memcmp" (or ___memcmp64 for 64-bit AIX OS), it will change the call target.
https://github.com/llvm/llvm-project/pull/147093
More information about the llvm-commits
mailing list