[PATCH] D29668: Elide argument copies during instruction selection

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 7 11:53:40 PST 2017


rnk created this revision.
Herald added a subscriber: igorb.

Avoids tons of prologue boilerplate when arguments are passed in memory
and left in memory. This can happen in a debug build or in a release
build when an argument alloca is escaped.  This will dramatically affect
the code size of x86 debug builds, because X86 fast isel doesn't handle
arguments passed in memory at all. It only handles the x86_64 case of up
to 6 basic register parameters.

This is implemented by analyzing the entry block before to ISel to
identify copy elision candidates. If an argument is a copy elision
candidate, we set a flag on the InputArg that we pass to
TargetLowering::LowerFormalArguments, similar to how we mark byval
arguments. The target does normal calling convention processing to
compute argument locations, and if the argument lives in memory and the
target recognizes the elision candidate flag, it will return a
FrameIndexSDNode instead of the usual load or physical register copy
SDValue. The generic ISel code recognizes this and replaces the old
frame index with the new fixed frame index in the StaticAllocaMap and
the debug declare table.

Supersedes https://reviews.llvm.org/D28388

Fixes PR26328


https://reviews.llvm.org/D29668

Files:
  include/llvm/CodeGen/MachineFrameInfo.h
  include/llvm/CodeGen/SelectionDAGISel.h
  include/llvm/Target/TargetCallingConv.h
  lib/CodeGen/AsmPrinter/DwarfDebug.h
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  lib/Target/X86/X86ISelLowering.cpp
  test/CodeGen/X86/2010-04-30-LocalAlloc-LandingPad.ll
  test/CodeGen/X86/arg-copy-elide.ll
  test/CodeGen/X86/inline-asm-tied.ll
  test/CodeGen/X86/pr30430.ll
  test/CodeGen/X86/sse-intrinsics-fast-isel.ll
  test/CodeGen/X86/win64_eh.ll
  test/DebugInfo/X86/discriminator.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29668.87492.patch
Type: text/x-patch
Size: 25082 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170207/3420f40f/attachment-0001.bin>


More information about the llvm-commits mailing list