[llvm] [llvm][ARM]Add widen strings pass (PR #107120)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 16 08:55:51 PDT 2024
================
@@ -2029,6 +2031,145 @@ OptimizeFunctions(Module &M,
return Changed;
}
+static bool IsCharArray(Type *t) {
+ const unsigned int CHAR_BIT_SIZE = 8;
+ return t && t->isArrayTy() && t->getArrayElementType()->isIntegerTy() &&
+ t->getArrayElementType()->getIntegerBitWidth() == CHAR_BIT_SIZE;
+}
+
+static bool
+tryWidenGlobalStrings(Function &F,
+ function_ref<TargetTransformInfo &(Function &)> GetTTI) {
+ bool changed = false;
+
+ for (Function::iterator b = F.begin(); b != F.end(); ++b) {
+ for (BasicBlock::iterator i = b->begin(); i != b->end(); ++i) {
+ CallInst *CI = dyn_cast<CallInst>(i);
+ if (!CI) {
+ continue;
+ }
+
+ TargetTransformInfo &TTI = GetTTI(F);
+
+ Function *CallMemcpy = CI->getCalledFunction();
+ // find out if the current call instruction is a call to llvm memcpy
+ // intrinsics
+ if (CallMemcpy == NULL || !CallMemcpy->isIntrinsic() ||
+ CallMemcpy->getIntrinsicID() != Intrinsic::memcpy) {
----------------
davemgreen wrote:
Can this use `TLI->getLibFunc(*CI, Func)` and check it is LibFunc_memcpy?
https://github.com/llvm/llvm-project/pull/107120
More information about the llvm-commits
mailing list