[PATCH] D11160: Targets: commonize some stack realignment code

JF Bastien jfb at chromium.org
Mon Jul 13 14:18:23 PDT 2015


jfb created this revision.
jfb added a reviewer: sunfish.
jfb added a subscriber: llvm-commits.
Herald added subscribers: jfb, aemerson.

** This patch requires some discussion, it contains a breaking change **

This patch does the following:
* Fix FIXME on needsStackRealignment: it is now shared between multiple targets, implemented in TargetRegisterInfo.
* Factor out canRealignStack as a virtual function on TargetRegisterInfo, by default only looks for the `no-realign-stack` function attribute.

Multiple targets duplicated the same needsStackRealignment code:
 - Aarch64.
 - ARM.
 - Mips almost: had extra DEBUG diagnostic. Should the default implementation also have this diagnostic?
 - PowerPC.
 - WebAssembly.
 - x86 almost: has an extra force-align-stack option, and is otherwise the same as the default implementation. Should this option be shared by all targets?

The default implementation of needsStackRealignment used to just return false. My current patch changes the behavior by simply using the above shared behavior. This affects:
 - AMDGPU
 - BPF
 - CppBackend
 - MSP430
 - NVPTX
 - Sparc
 - SystemZ
 - XCore
 - Out-of-tree targets
This is a breaking change! Is this OK? `make check` passes.

The only implementation of the virtual function (besides the slight different in x86) is now Hexagon (does `MF.getFrameInfo()->getMaxAlignment() > 8`), and potentially some out-of-tree targets. Should Haxagon simply use the default implementation?

needsStackRealignment was being overwritten in <Target>GenRegisterInfo.inc, to return false as the default also did. That was odd.

http://reviews.llvm.org/D11160

Files:
  include/llvm/Target/TargetRegisterInfo.h
  lib/CodeGen/TargetRegisterInfo.cpp
  lib/Target/AArch64/AArch64RegisterInfo.cpp
  lib/Target/AArch64/AArch64RegisterInfo.h
  lib/Target/ARM/ARMBaseRegisterInfo.cpp
  lib/Target/ARM/ARMBaseRegisterInfo.h
  lib/Target/Mips/MipsRegisterInfo.cpp
  lib/Target/Mips/MipsRegisterInfo.h
  lib/Target/PowerPC/PPCRegisterInfo.cpp
  lib/Target/PowerPC/PPCRegisterInfo.h
  lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp
  lib/Target/WebAssembly/WebAssemblyRegisterInfo.h
  lib/Target/X86/X86RegisterInfo.cpp
  lib/Target/X86/X86RegisterInfo.h
  utils/TableGen/RegisterInfoEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11160.29606.patch
Type: text/x-patch
Size: 15529 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150713/1a5816d1/attachment.bin>


More information about the llvm-commits mailing list