[all-commits] [llvm/llvm-project] 0276fa: [X86][ABI] Don't preserve return regs for preserve...
Anton Bikineev via All-commits
all-commits at lists.llvm.org
Mon Jan 23 04:32:38 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0276fa89d7a4dbe73105c9148f947716b3d8f17f
https://github.com/llvm/llvm-project/commit/0276fa89d7a4dbe73105c9148f947716b3d8f17f
Author: Anton Bikineev <bikineev at chromium.org>
Date: 2023-01-23 (Mon, 23 Jan 2023)
Changed paths:
M llvm/docs/LangRef.rst
M llvm/lib/Target/X86/X86CallingConv.td
M llvm/lib/Target/X86/X86ISelLowering.cpp
A llvm/test/CodeGen/X86/preserve_allcc64-ret-double.ll
M llvm/test/CodeGen/X86/preserve_allcc64.ll
A llvm/test/CodeGen/X86/preserve_mostcc64-ret-double.ll
M llvm/test/CodeGen/X86/preserve_mostcc64.ll
Log Message:
-----------
[X86][ABI] Don't preserve return regs for preserve_all/preserve_most CCs
Currently both calling conventions preserve registers that are used to
store a return value. This causes the returned value to be lost:
define i32 @bar() {
%1 = call preserve_mostcc i32 @foo()
ret i32 %1
}
define preserve_mostcc i32 @foo() {
ret i32 2
; preserve_mostcc will restore %rax,
; whatever it was before the call.
}
This contradicts the current documentation (preserve_allcc "behaves
identical to the `C` calling conventions on how arguments and return
values are passed") and also breaks [[clang::preserve_most]].
This change makes CSRs be preserved iff they are not used to store a
return value (e.g. %rax for scalars, {%rax:%rdx} for __int128, %xmm0
for double). For void functions no additional registers are
preserved, i.e. the behaviour is backward compatible with existing
code.
Differential Revision: https://reviews.llvm.org/D141020
More information about the All-commits
mailing list