[PATCH] D147484: [AArch64][GlobalISel] Move the localizer to run before the legalizer, and always localize globals.

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 3 16:24:05 PDT 2023


aemerson created this revision.
aemerson added a reviewer: paquette.
aemerson added a project: LLVM.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
aemerson requested review of this revision.

Our strategy for localizing globals in the entry block breaks down when we have
large functions with high register pressure, using lots of globals. When this
happens, our heuristics say that globals with many uses should not be localized,
leading us to cause excessive spills and stack usage. These situations are also
exacerbated by LTO which tends to generate large functions.

For now, moving to a strategy that's simpler and more akin to SelectionDAG
fixes these issues and makes our codegen more similar. This has an overall
neutral effect on size on CTMark, while showing slight improvements with -Os -flto
on benchmarks. For low level firmware software though we see big improvements.

The reason this is neutral, and not an improvement, is because we give up the
gains from CSE'ing globals in cases where we low register pressure. I think
this can be addressed in future with some better heuristics.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147484

Files:
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/arm64-atomic.ll
  llvm/test/CodeGen/AArch64/GlobalISel/arm64-pcsections.ll
  llvm/test/CodeGen/AArch64/GlobalISel/gisel-commandline-option.ll
  llvm/test/CodeGen/AArch64/GlobalISel/invoke-region.ll
  llvm/test/CodeGen/AArch64/GlobalISel/legalize-exceptions.ll
  llvm/test/CodeGen/AArch64/GlobalISel/localizer-arm64-tti.ll
  llvm/test/CodeGen/AArch64/GlobalISel/localizer-in-O0-pipeline.mir
  llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-lowering-swap-compare-operands.mir
  llvm/test/CodeGen/AArch64/O0-pipeline.ll
  llvm/test/CodeGen/AArch64/aarch64-mops-mte.ll
  llvm/test/CodeGen/AArch64/aarch64-mops.ll
  llvm/test/CodeGen/AArch64/popcount.ll
  llvm/test/Other/print-changed-machine.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147484.510640.patch
Type: text/x-patch
Size: 77632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230403/dfed59c8/attachment-0001.bin>


More information about the llvm-commits mailing list