From 998a7938ca2099b43297c7f99146e99c776501af Mon Sep 17 00:00:00 2001
From: clc5q <clc5q@git.zephyr-software.com>
Date: Fri, 22 Jan 2016 15:34:36 +0000
Subject: [PATCH] Clean up handling of no-ops.

Former-commit-id: 790c5f55fbd87430d349dbb6094fa2ca35f1aa4c
---
 src/base/SMPFunction.cpp | 5 ++++-
 src/base/SMPInstr.cpp    | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp
index e959fce1..d34e4f46 100644
--- a/src/base/SMPFunction.cpp
+++ b/src/base/SMPFunction.cpp
@@ -1897,7 +1897,7 @@ void SMPFunction::FindFramePointerDelta(void) {
 			}
 		}
 		else if (!SPintoFP) { // found "push <framepointerreg>", looking for "fp := sp"
-			if ((CurrInst->GetIDAOpcode() == MD_MOVE_INSTRUCTION) 
+			if ((CurrInst->GetIDAOpcode() == MD_MOVE_INSTRUCTION) && CurrInst->IsAnalyzeable()
 				&& (CurrInst->GetFirstDef()->GetOp()->MatchesReg(MD_FRAME_POINTER_REG))
 				&& (CurrInst->GetFirstUse()->GetOp()->MatchesReg(MD_STACK_POINTER_REG))) {
 				SPintoFP = true;
@@ -2035,6 +2035,9 @@ bool SMPFunction::MDFixFrameInfo(void) {
 	for ( ; CurrIter != CurrBlock->GetLastInst(); ++CurrIter) {
 		SMPInstr *CurrInstr = (*CurrIter);
 		STARS_ea_t InstAddr = CurrInstr->GetAddr();
+		if (!CurrInstr->IsAnalyzeable())
+			continue;
+
 		if (FoundAllocInstr && (DEFAULT != CurrInstr->GetDataFlowType())) {
 			// After we find the frame allocation instruction, a call or any other
 			//  control flow instruction should terminate our processing. A stack
diff --git a/src/base/SMPInstr.cpp b/src/base/SMPInstr.cpp
index 8fa1aa31..9936e18c 100644
--- a/src/base/SMPInstr.cpp
+++ b/src/base/SMPInstr.cpp
@@ -3151,7 +3151,7 @@ bool SMPInstr::MDIsFrameDeallocInstr(bool UseFP, STARS_asize_t LocalVarsSize) {
 	unsigned short opcode = this->GetIDAOpcode();
 	if ((opcode >= MD_FIRST_LEAVE_INSTR) && (opcode <= MD_LAST_LEAVE_INSTR))
 		return true;
-	else if (this->HasDestMemoryOperand() || this->HasSourceMemoryOperand()) {
+	else if (this->HasDestMemoryOperand() || this->HasSourceMemoryOperand() || (!this->IsAnalyzeable())) {
 		// Don't get fooled by USE or DEF entries of EBP or ESP that come
 		//  from memory operands, e.g. mov eax,[ebp-20]
 		return false;
@@ -5255,6 +5255,9 @@ void SMPInstr::BuildSMPDefUseLists(void) {
 	this->Defs.clear();
 	this->Uses.clear();
 
+	if (this->IsNop())
+		return;
+
 	// Start with the Defs.
 	for (OpNum = 0; OpNum < STARS_UA_MAXOP; ++OpNum) {
 		if (this->STARSInstPtr->IsDefOpnd(OpNum)) { // DEF
-- 
GitLab