[PATCH] D107872: [SimplifyLibCalls] propagate tail/musttail/notail flags on CallInsts

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 12 10:54:52 PDT 2021


jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG, with some missing checks that can be added for the final version.



================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:1159
              : Constant::getNullValue(CI->getType());
 }
 
----------------
Musttail check for this one?


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:1378
+      return B.CreateFNeg(
+          copyFlags(*Call, B.CreateCall(Call->getCalledFunction(), X)));
     break;
----------------
Also not allowed to be musttail.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:1643
     Function *FAbsFn = Intrinsic::getDeclaration(Mod, Intrinsic::fabs, Ty);
-    Sqrt = B.CreateCall(FAbsFn, Sqrt, "abs");
+    Sqrt = copyFlags(*Pow, B.CreateCall(FAbsFn, Sqrt, "abs"));
   }
----------------
copy flags only if not musstail or we actually return "this Sqrt".


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:2618
+            ConstantInt::get(DL.getIntPtrType(CI->getContext()),
+                             FormatStr.size() + 1))); // Copy the null byte.
     return ConstantInt::get(CI->getType(), FormatStr.size());
----------------
Musttail check?


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:2660
+                              ConstantInt::get(CI->getType(), Str.size() + 1)));
 
       // The snprintf result is the unincremented number of bytes in the string.
----------------
Musttail check?


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:3372
+  copyFlags(*CI, cast<CallInst>(Ret));
   return Ret;
 }
----------------
make it `return copyFlags` so it's easy to see this doesn't need a guard.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107872



More information about the llvm-commits mailing list