From 9e9e9254befdbfedf3b614f575bc01f271c50879 Mon Sep 17 00:00:00 2001
From: clc5q <clc5q@git.zephyr-software.com>
Date: Thu, 16 Jul 2015 03:27:01 +0000
Subject: [PATCH] Continue to simplify and combine early stack frame loops
 through instructions.

Former-commit-id: 2be6870cc28d4618ec59207485533080f8b333f2
---
 src/base/SMPFunction.cpp                             | 12 +++++++++++-
 ...med-sorted-save-ffmpeg.psexe.annot.REMOVED.git-id |  2 +-
 ...mmed-sorted-save-gedit.psexe.annot.REMOVED.git-id |  2 +-
 ...-save-gnome-calculator.psexe.annot.REMOVED.git-id |  2 +-
 ...save-gnome-search-tool.psexe.annot.REMOVED.git-id |  2 +-
 .../trimmed-sorted-save-gnome-system-log.psexe.annot | 12 ++++++++----
 ...save-gnome-text-editor.psexe.annot.REMOVED.git-id |  2 +-
 ...d-sorted-save-synaptic.psexe.annot.REMOVED.git-id |  2 +-
 ...mmed-sorted-save-xedit.psexe.annot.REMOVED.git-id |  2 +-
 9 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp
index 250077ea..5849e200 100644
--- a/src/base/SMPFunction.cpp
+++ b/src/base/SMPFunction.cpp
@@ -1741,6 +1741,7 @@ void SMPFunction::FindPreservedRegs(void) {
 void SMPFunction::FindAllAllocsAndDeallocs(void) {
 	bool FoundAllocInstr = false;
 	bool FoundDeallocInstr = false;
+	bool FoundAlloca = false;
 	bool DebugFlag = false;
 #if SMP_DEBUG_FRAMEFIXUP
 	DebugFlag |= (0 == strcmp("frame_dummy", this->GetFuncName()));
@@ -1776,8 +1777,18 @@ void SMPFunction::FindAllAllocsAndDeallocs(void) {
 				this->LocalVarsDeallocInstr = addr;
 				FoundDeallocInstr = true;
 			}
+			else if (CurrInst->MDIsFrameAllocInstr()) {
+				FoundAlloca = true;
+				if (CurrInst->HasAllocaRTL()) {
+					CurrInst->SetAllocaCall();
+				}
+			}
+			else if (CurrInst->MDIsPushInstr()) {
+				this->PushAfterLocalVarAlloc = true;
+			}
 		}
 	}
+	this->CallsAlloca = FoundAlloca;
 
 	// As of July, 2015, the code below seems unnecessary and obsolete.
 	return;
@@ -4038,7 +4049,6 @@ void SMPFunction::AdvancedAnalysis(void) {
 #endif
 
 	this->FindAllAllocsAndDeallocs();
-	this->CallsAlloca = this->FindAlloca();
 
 #if 1
 	InstIter = this->Instrs.begin();
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 68d007c8..67214814 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 @@
-0e2d8771ec154d31994de0770e66330bd2e49ac4
\ No newline at end of file
+56927c3206cc0229b61ac271e9ef366bf853b5c7
\ No newline at end of file
diff --git a/tests/commit/trimmed-sorted-save-gedit.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-gedit.psexe.annot.REMOVED.git-id
index 90d2af3d..6dd12551 100644
--- a/tests/commit/trimmed-sorted-save-gedit.psexe.annot.REMOVED.git-id
+++ b/tests/commit/trimmed-sorted-save-gedit.psexe.annot.REMOVED.git-id
@@ -1 +1 @@
-d4d6e5c44bc8a949da730f46219d3ca2b30ca958
\ No newline at end of file
+8e19d369a97c50fed8b65efe3371b64d28a0f25e
\ No newline at end of file
diff --git a/tests/commit/trimmed-sorted-save-gnome-calculator.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-gnome-calculator.psexe.annot.REMOVED.git-id
index cd249953..0d2c2589 100644
--- a/tests/commit/trimmed-sorted-save-gnome-calculator.psexe.annot.REMOVED.git-id
+++ b/tests/commit/trimmed-sorted-save-gnome-calculator.psexe.annot.REMOVED.git-id
@@ -1 +1 @@
-8f2a86f1deb39e8c6fbb4e232768c464e6b33f99
\ No newline at end of file
+a45d85572cac4aa1c097233cfabe417bd221e35c
\ No newline at end of file
diff --git a/tests/commit/trimmed-sorted-save-gnome-search-tool.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-gnome-search-tool.psexe.annot.REMOVED.git-id
index 384617e1..167b6120 100644
--- a/tests/commit/trimmed-sorted-save-gnome-search-tool.psexe.annot.REMOVED.git-id
+++ b/tests/commit/trimmed-sorted-save-gnome-search-tool.psexe.annot.REMOVED.git-id
@@ -1 +1 @@
-fb461cb1fb815ae8456b96f324d8f9420b9afdab
\ No newline at end of file
+2d26ae88c9b3c1dc8a0969d5b04fbed84655bd7d
\ No newline at end of file
diff --git a/tests/commit/trimmed-sorted-save-gnome-system-log.psexe.annot b/tests/commit/trimmed-sorted-save-gnome-system-log.psexe.annot
index b87db225..f684ba7e 100644
--- a/tests/commit/trimmed-sorted-save-gnome-system-log.psexe.annot
+++ b/tests/commit/trimmed-sorted-save-gnome-system-log.psexe.annot
@@ -6592,16 +6592,20 @@
     40b337      1 INSTR DEADREGS  EFLAGS R8 R9 R10 R11 ZZ pop     rbp 
     40b338      1 INSTR BELONGTO 40b2b0 
     40b338      1 INSTR DEADREGS  EFLAGS R8 R9 R10 R11 ZZ retn 
-    40b340     -1 INSTR LOCAL MetadataUnused mov     [rsp+var_20], rbx 
     40b340      5 INSTR BELONGTO 40d6c0 
-    40b345     -1 INSTR LOCAL MetadataUnused mov     [rsp+var_18], rbp 
+    40b340      5 INSTR DEADREGS  EFLAGS RAX RCX RDX RSI R8 R9 R10 R11 ZZ mov     [rsp+var_20], rbx 
+    40b340      5 PTRIMMEDESP STACK -32 displ mov     [rsp+var_20], rbx
     40b345      5 INSTR BELONGTO 40d6c0 
+    40b345      5 INSTR DEADREGS  EFLAGS RAX RCX RDX RBX RSI R8 R9 R10 R11 ZZ mov     [rsp+var_18], rbp 
+    40b345      5 PTRIMMEDESP STACK -24 displ mov     [rsp+var_18], rbp
     40b34a      3 INSTR BELONGTO 40d6c0 
     40b34a      3 INSTR DEADREGS  EFLAGS RAX RCX RDX RBX RSI R8 R9 R10 R11 ZZ mov     rbx, rdi 
-    40b34d     -1 INSTR LOCAL MetadataUnused mov     [rsp+var_10], r12 
     40b34d      5 INSTR BELONGTO 40d6c0 
-    40b352     -1 INSTR LOCAL MetadataUnused mov     [rsp+var_8], r13 
+    40b34d      5 INSTR DEADREGS  EFLAGS RAX RCX RDX RSI RDI R8 R9 R10 R11 ZZ mov     [rsp+var_10], r12 
+    40b34d      5 PTRIMMEDESP STACK -16 displ mov     [rsp+var_10], r12
     40b352      5 INSTR BELONGTO 40d6c0 
+    40b352      5 INSTR DEADREGS  EFLAGS RAX RCX RDX RSI RDI R8 R9 R10 R11 R12 ZZ mov     [rsp+var_8], r13 
+    40b352      5 PTRIMMEDESP STACK -8 displ mov     [rsp+var_8], r13
     40b357      4 INSTR BELONGTO 40d6c0 
     40b357      4 INSTR DEADREGS  EFLAGS RAX RCX RDX RSI RDI R8 R9 R10 R11 R12 R13 ZZ sub     rsp, 28h 
     40b35b     -1 INSTR LOCAL NoMetaUpdate call    sub_40A9B0 
diff --git a/tests/commit/trimmed-sorted-save-gnome-text-editor.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-gnome-text-editor.psexe.annot.REMOVED.git-id
index 90d2af3d..6dd12551 100644
--- a/tests/commit/trimmed-sorted-save-gnome-text-editor.psexe.annot.REMOVED.git-id
+++ b/tests/commit/trimmed-sorted-save-gnome-text-editor.psexe.annot.REMOVED.git-id
@@ -1 +1 @@
-d4d6e5c44bc8a949da730f46219d3ca2b30ca958
\ No newline at end of file
+8e19d369a97c50fed8b65efe3371b64d28a0f25e
\ No newline at end of file
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 067937d6..e18ed786 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 @@
-eb257b113ba86c2f98b100bfe10a16eea25ba075
\ No newline at end of file
+4b2e34138721c306a3ce209c2a4068f77a583d68
\ 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 823dbe8d..d881c734 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 @@
-93cfcad302be8656efd4bad4c32501c847964eea
\ No newline at end of file
+f918b9cf9e90d2121fc14747c9396aead54585af
\ No newline at end of file
-- 
GitLab