From 901ac80026f3defad4c143d2336558384bd763ad Mon Sep 17 00:00:00 2001 From: Lauri Kasanen Date: Fri, 19 May 2017 15:20:36 +0300 Subject: [PATCH] Wrapper functions use all registers --- src/cc65/codeinfo.c | 4 ++++ src/cc65/funcdesc.h | 3 ++- src/cc65/pragma.c | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cc65/codeinfo.c b/src/cc65/codeinfo.c index de51781a6..06c66baf4 100644 --- a/src/cc65/codeinfo.c +++ b/src/cc65/codeinfo.c @@ -401,6 +401,10 @@ void GetFuncInfo (const char* Name, unsigned short* Use, unsigned short* Chg) */ if ((D->Flags & FD_VARIADIC) != 0) { *Use = REG_Y; + } else if (D->Flags & FD_CALL_WRAPPER) { + /* Wrappers may go to any functions, so mark them as using all + registers */ + *Use = REG_EAXY; } else if (D->ParamCount > 0 && (AutoCDecl ? IsQualFastcall (E->Type) : diff --git a/src/cc65/funcdesc.h b/src/cc65/funcdesc.h index 040f6e97c..a04ffb14a 100644 --- a/src/cc65/funcdesc.h +++ b/src/cc65/funcdesc.h @@ -52,9 +52,10 @@ #define FD_OLDSTYLE 0x0010U /* Old style (K&R) function */ #define FD_OLDSTYLE_INTRET 0x0020U /* K&R func has implicit int return */ #define FD_UNNAMED_PARAMS 0x0040U /* Function has unnamed params */ +#define FD_CALL_WRAPPER 0x0080U /* This function is used as a wrapper */ /* Bits that must be ignored when comparing funcs */ -#define FD_IGNORE (FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS) +#define FD_IGNORE (FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS | FD_CALL_WRAPPER) diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 8d5dfd8b1..3dfc62668 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -513,6 +513,7 @@ static void WrappedCallPragma (StrBuf* B) PushWrappedCall(Entry, Val); Entry->Flags |= SC_REF; + Entry->V.F.Func->Flags |= FD_CALL_WRAPPER; } else { -- 2.39.5