From b04f453e53642496a235d5b014b34446bd2a5d91 Mon Sep 17 00:00:00 2001
From: clc5q <clc5q@git.zephyr-software.com>
Date: Sun, 20 Apr 2008 00:06:38 +0000
Subject: [PATCH] Add DEFs of caller-saved regs to CALL instructions.

---
 SMPInstr.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/SMPInstr.cpp b/SMPInstr.cpp
index 4cf4a8c5..fec0ace0 100644
--- a/SMPInstr.cpp
+++ b/SMPInstr.cpp
@@ -35,6 +35,7 @@
 #define SMP_VERBOSE_DEBUG_INFER_TYPES 0
 #define SMP_VERBOSE_DUMP 0
 
+#define SMP_CALL_TRASHES_REGS 1  // Add DEFs of caller-saved regs to CALL instructions
 #define SMP_BASEREG_POINTER_TYPE 0  // Initialize Base Register USEs to type POINTER?
 
 // Make the CF_CHG1 .. CF_CHG6 and CF_USE1..CF_USE6 macros more usable
@@ -942,6 +943,14 @@ void SMPInstr::MDFixupDefUseLists(void) {
 			}
 		}
 	}
+#if SMP_CALL_TRASHES_REGS
+	else if ((this->type == CALL) || (this->type == INDIR_CALL)) {
+		// We want to add the caller-saved registers to the DEFs list
+		this->MDAddRegDef(R_ax, false);
+		this->MDAddRegDef(R_cx, false);
+		this->MDAddRegDef(R_dx, false);
+	}
+#endif
 	else if (this->MDIsEnterInstr() || this->MDIsLeaveInstr()) {
 		// Entire function prologue or epilogue microcoded.
 		this->MDAddRegDef(R_sp, false);
-- 
GitLab