[PATCH] D131034: [Backend][X86] Improved tail call optimization for functions marked as musttail

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 4 10:38:41 PDT 2022


davidxl added inline comments.


================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:4267
+    if (IsMustTail)
+      IsSibcall = CanTailCall;
+    else {
----------------
Can this be handled by line 4274?


================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:4314
   int FPDiff = 0;
-  if (isTailCall &&
+  if (isTailCall && !IsSibcall &&
       shouldGuaranteeTCO(CallConv,
----------------
what is this change for?


================
Comment at: llvm/test/CodeGen/X86/musttail-struct.ll:41
+
+; Arguments of different sizes passed on stack.
+define dso_local i32 @testManyArgs(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i8 %6, ptr byval(%struct.5xi32) %7) {
----------------
huangjd wrote:
> davidxl wrote:
> > huangjd wrote:
> > > davidxl wrote:
> > > > is this the correct comment, or it is intended for a negative test (missing)?
> > > This is just describing the purpose of the test. in x64 the first 6 are passed by register and the rest 2 are passed by stack
> > Ok. Can you expand the comment a little more.
> > 
> > Can you also add a negative test?
> I am not sure what should a negative test be in this case, since the front end rejects the code if "musttail" is applied on function call that can't be tail called. Also if tail call is not applied, the output assembly can be quite unpredictable (if someone else change anything else in codegen) since instructions can be shuffled. I have yet seen a negative test with tail call optimization
An IR test can be written manually.  This is to test line 4262: IsEligibleForTailCallOptimization() logic for mustTail case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131034



More information about the llvm-commits mailing list