[PATCH] D157848: [PreISelIntrinsicLowering] Use TLI for correct function

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 16 01:02:31 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG66bb75216258: [PreISelIntrinsicLowering] Use TLI for correct function (authored by nikic).

Changed prior to commit:
  https://reviews.llvm.org/D157848?vs=549845&id=550652#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157848/new/

https://reviews.llvm.org/D157848

Files:
  llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp


Index: llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
===================================================================
--- llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
+++ llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
@@ -197,15 +197,16 @@
   return SizeVal > Threshold || Threshold == 0;
 }
 
-static bool canEmitLibcall(const TargetLowering &TLI, RTLIB::Libcall LC) {
+static bool canEmitLibcall(const TargetMachine &TM, Function *F,
+                           RTLIB::Libcall LC) {
   // TODO: Should this consider the address space of the memcpy?
-  return TLI.getLibcallName(LC) != nullptr;
+  const TargetLowering *TLI = TM.getSubtargetImpl(*F)->getTargetLowering();
+  return TLI->getLibcallName(LC) != nullptr;
 }
 
 // TODO: Handle atomic memcpy and memcpy.inline
 // TODO: Pass ScalarEvolution
 bool PreISelIntrinsicLowering::expandMemIntrinsicUses(Function &F) const {
-  const TargetLowering *TLI = TM.getSubtargetImpl(F)->getTargetLowering();
   Intrinsic::ID ID = F.getIntrinsicID();
   bool Changed = false;
 
@@ -218,7 +219,8 @@
       Function *ParentFunc = Memcpy->getFunction();
       const TargetTransformInfo &TTI = LookupTTI(*ParentFunc);
       if (shouldExpandMemIntrinsicWithSize(Memcpy->getLength(), TTI)) {
-        if (UseMemIntrinsicLibFunc && canEmitLibcall(*TLI, RTLIB::MEMCPY))
+        if (UseMemIntrinsicLibFunc &&
+            canEmitLibcall(TM, ParentFunc, RTLIB::MEMCPY))
           break;
 
         // TODO: For optsize, emit the loop into a separate function
@@ -234,7 +236,8 @@
       Function *ParentFunc = Memmove->getFunction();
       const TargetTransformInfo &TTI = LookupTTI(*ParentFunc);
       if (shouldExpandMemIntrinsicWithSize(Memmove->getLength(), TTI)) {
-        if (UseMemIntrinsicLibFunc && canEmitLibcall(*TLI, RTLIB::MEMMOVE))
+        if (UseMemIntrinsicLibFunc &&
+            canEmitLibcall(TM, ParentFunc, RTLIB::MEMMOVE))
           break;
 
         if (expandMemMoveAsLoop(Memmove, TTI)) {
@@ -250,7 +253,8 @@
       Function *ParentFunc = Memset->getFunction();
       const TargetTransformInfo &TTI = LookupTTI(*ParentFunc);
       if (shouldExpandMemIntrinsicWithSize(Memset->getLength(), TTI)) {
-        if (UseMemIntrinsicLibFunc && canEmitLibcall(*TLI, RTLIB::MEMSET))
+        if (UseMemIntrinsicLibFunc &&
+            canEmitLibcall(TM, ParentFunc, RTLIB::MEMSET))
           break;
 
         expandMemSetAsLoop(Memset);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157848.550652.patch
Type: text/x-patch
Size: 2404 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230816/a96c9922/attachment.bin>


More information about the llvm-commits mailing list