This is an archive of the discontinued LLVM Phabricator instance.

[X86] Deduplicate static calling convention helpers for code size, NFC
ClosedPublic

Authored by rnk on Jan 17 2019, 4:12 PM.

Details

Summary

Right now we include ${TGT}GenCallingConv.inc once per each instruction
selection method implemented by ${TGT}:

  • ${TGT}ISelLowering.cpp
  • ${TGT}CallLowering.cpp
  • ${TGT}FastISel.cpp

Instead, add a mechanism to tablegen for marking a particular convention
as "External", which causes tablegen to emit into the ::llvm namespace,
instead of as a static helper. This allows us to provide a header to
forward declare it, so we can simply call the function from all the
places it is referenced. Typically the calling convention analyzer is
called indirectly, so it doesn't benefit from inlining.

This saves a bit of final binary size, but mostly just saves object file
size:

before after diff artifact
12852K 12492K -360K X86ISelLowering.cpp.obj
4640K 4280K -360K X86FastISel.cpp.obj
1704K 2092K +388K X86CallingConv.cpp.obj
52448K 52336K -112K llc.exe

I didn't collect before numbers for X86CallLowering.cpp.obj, which is
for GlobalISel, but we should save 360K there as well.

This patch applies the strategy to the X86 backend, but there is no
reason it couldn't be applied to the other backends that implement
multiple ISel strategies, like AArch64.

Diff Detail

Repository
rL LLVM

Event Timeline

rnk created this revision.Jan 17 2019, 4:12 PM
rnk updated this revision to Diff 182620.Jan 18 2019, 3:22 PM
  • fix formatting
  • rebase
This revision is now accepted and ready to land.Jan 18 2019, 4:23 PM
This revision was automatically updated to reflect the committed changes.
wxiao3 added a subscriber: wxiao3.Jan 20 2019, 4:45 PM