From 129397bb02edaff182cdc085c8357e8e23b4b097 Mon Sep 17 00:00:00 2001
From: clc5q <clc5q@git.zephyr-software.com>
Date: Fri, 31 Jul 2015 20:47:46 +0000
Subject: [PATCH] Better tail call definition, fewer ERROR log messages on tail
 calls.

Former-commit-id: 078c4294c5c37971ccada1addb4abe2f4b156ac8
---
 src/base/SMPFunction.cpp                                    | 6 +++---
 .../trimmed-sorted-save-ffmpeg.psexe.annot.REMOVED.git-id   | 2 +-
 .../trimmed-sorted-save-gnome-control-center.psexe.annot    | 2 +-
 .../trimmed-sorted-save-synaptic.psexe.annot.REMOVED.git-id | 2 +-
 .../trimmed-sorted-save-xedit.psexe.annot.REMOVED.git-id    | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp
index a735bf98..9bd7ea67 100644
--- a/src/base/SMPFunction.cpp
+++ b/src/base/SMPFunction.cpp
@@ -1380,9 +1380,9 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) {
 				CurrInst->SetStackPtrOffset(IncomingDelta);
 
 				// Search for tail calls, defined strictly as having an incoming stack delta of zero and
-				//  being jumps to far chunks.
+				//  being jumps to far chunks not include in the current function.
 				if (0 == IncomingDelta) {
-					if (CurrInst->IsBranchToFarChunk()) {
+					if (CurrInst->IsBranchToFarChunk() && (!this->IsInstIDInFunc(CurrInst->GetFarBranchTarget()))) {
 						CurrInst->SetTailCall();
 #if 0
 						SMP_msg("INFO: Found tail call at %llx from %s: %s\n", (unsigned long long) InstAddr, this->GetFuncName(),
@@ -1393,7 +1393,7 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) {
 						// We have an indirect jump with an incoming delta of zero. This
 						//  is probably an indirect tail call, unless the target address has
 						//  been resolved to addresses in the current function (e.g. switch table).
-						if (this->HasUnresolvedIndirectJumps()) {
+						if (this->HasUnresolvedIndirectJumps() && (STARS_BADADDR == CurrInst->GetCallTarget())) {
 							CurrInst->SetTailCall();
 #if 0
 							SMP_msg("INFO: Found indirect tail call at %llx from %s: %s\n", (unsigned long long) InstAddr, this->GetFuncName(),
diff --git a/tests/commit/trimmed-sorted-save-ffmpeg.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-ffmpeg.psexe.annot.REMOVED.git-id
index bd67835c..22994728 100644
--- a/tests/commit/trimmed-sorted-save-ffmpeg.psexe.annot.REMOVED.git-id
+++ b/tests/commit/trimmed-sorted-save-ffmpeg.psexe.annot.REMOVED.git-id
@@ -1 +1 @@
-831f69765e5bc395de3f27327555f4a3b85f5cdb
\ No newline at end of file
+d9408921f2d567da87921546d8878c9f12709b9c
\ No newline at end of file
diff --git a/tests/commit/trimmed-sorted-save-gnome-control-center.psexe.annot b/tests/commit/trimmed-sorted-save-gnome-control-center.psexe.annot
index 16564e32..872d6ff5 100644
--- a/tests/commit/trimmed-sorted-save-gnome-control-center.psexe.annot
+++ b/tests/commit/trimmed-sorted-save-gnome-control-center.psexe.annot
@@ -5811,7 +5811,7 @@
               9172      6 INSTR BELONGTO 9140 
               9178     10 INSTR BELONGTO 9140 
               9178     10 INSTR DEADREGS  EFLAGS RCX RBX ZZ mov     rcx, 2000000020000h 
-              9178     -2 INSTR LOCAL n RCX ZZ  NumericDEFs mov     rcx, 2000000020000h 
+              9178     -2 INSTR LOCAL n RCX ZZ  NUMVia2ndSrcIMMEDNUM mov     rcx, 2000000020000h 
               9182     -1 INSTR LOCAL NoMetaUpdate test    rax, rcx 
               9182      3 INSTR BELONGTO 9140 
               9185     -1 INSTR LOCAL NoMetaUpdate jnz     short loc_91B8 
diff --git a/tests/commit/trimmed-sorted-save-synaptic.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-synaptic.psexe.annot.REMOVED.git-id
index c1749668..40ed2cce 100644
--- a/tests/commit/trimmed-sorted-save-synaptic.psexe.annot.REMOVED.git-id
+++ b/tests/commit/trimmed-sorted-save-synaptic.psexe.annot.REMOVED.git-id
@@ -1 +1 @@
-9feaeb7eb4b9cabd1744d23576f27f37c8263f75
\ No newline at end of file
+a83ce7d7e40d5bf011274918b68a2219b5a3679f
\ No newline at end of file
diff --git a/tests/commit/trimmed-sorted-save-xedit.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-xedit.psexe.annot.REMOVED.git-id
index 14700610..c842eb02 100644
--- a/tests/commit/trimmed-sorted-save-xedit.psexe.annot.REMOVED.git-id
+++ b/tests/commit/trimmed-sorted-save-xedit.psexe.annot.REMOVED.git-id
@@ -1 +1 @@
-352a213bfb3e1cc815b8527fe743314d7a597e74
\ No newline at end of file
+6db952769fca9820b203527c3a23e3264b5046c0
\ No newline at end of file
-- 
GitLab