summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lib/Target/X86/X86MachineFunctionInfo.h
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2019-01-30 03:08:12 +0000
committerdlg <dlg@openbsd.org>2019-01-30 03:08:12 +0000
commit728e23dfc36a7a5f9a19f349b6c8d489de3d3859 (patch)
treecd910b6c2a97a90f6de6b76e84d2d74246997cc1 /gnu/llvm/lib/Target/X86/X86MachineFunctionInfo.h
parentuse MPLS_SHIM2LABEL and MPLS_LABEL2SHIM (diff)
downloadwireguard-openbsd-728e23dfc36a7a5f9a19f349b6c8d489de3d3859.tar.xz
wireguard-openbsd-728e23dfc36a7a5f9a19f349b6c8d489de3d3859.zip
implement -msave-args in clang/llvm, like the sun did for gcc
this is a bit different to gcc as gcc likes to use movs to move stuff on and off the stack, and directly updates the stack pointers with add and sub instructions. llvm prefers to use push and pop instructions, is a lot more careful about keeping track of how much stuff is currently on the stack, and generally pops the frame pointer rather than do maths on it. -msave-args adds a bunch of pushes as the first thing a function prologue does. to keep the stack aligned, if there's an odd number of arguments to the function it pushes the first one again to put the frame back on a 16 byte boundary. to undo the pushes the frame pointer needs to be updated in function epilogues. clang emits a series of pops to fix up the registers on the way out, but popping saved arguments is a waste of time and harmful to actual data in the function. rather than add an offset to the stack pointer, -msave-args emits a leaveq operation to fix up the frame again. leaveq is effectively mov rbp,rsp; pop rbp, and is a single byte, meaning there's less potential for gadgets compared to a direct add to rsp, or an explicit mov rbp,rsp. the only thing missing compared to the gcc implementation is adding the SUN_amd64_parmdump dwarf flag to affected functions. if someone can tell me how to add that from the frame lowering code, let me know. when enabled in kernel builds again, this will provide useful arguments in ddb stack traces again.
Diffstat (limited to 'gnu/llvm/lib/Target/X86/X86MachineFunctionInfo.h')
-rw-r--r--gnu/llvm/lib/Target/X86/X86MachineFunctionInfo.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/gnu/llvm/lib/Target/X86/X86MachineFunctionInfo.h b/gnu/llvm/lib/Target/X86/X86MachineFunctionInfo.h
index e1183bd1479..393abe698db 100644
--- a/gnu/llvm/lib/Target/X86/X86MachineFunctionInfo.h
+++ b/gnu/llvm/lib/Target/X86/X86MachineFunctionInfo.h
@@ -41,6 +41,9 @@ class X86MachineFunctionInfo : public MachineFunctionInfo {
/// stack frame in bytes.
unsigned CalleeSavedFrameSize = 0;
+ // SaveArgSize - Number of register arguments saved on the stack
+ unsigned SaveArgSize = 0;
+
/// BytesToPopOnReturn - Number of bytes function pops on return (in addition
/// to the space used by the return address).
/// Used on windows platform for stdcall & fastcall name decoration
@@ -124,6 +127,9 @@ public:
unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
+ unsigned getSaveArgSize() const { return SaveArgSize; }
+ void setSaveArgSize(unsigned bytes) { SaveArgSize = bytes; }
+
unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
void setBytesToPopOnReturn (unsigned bytes) { BytesToPopOnReturn = bytes;}