From d7ce17c599a548bf5b99b9d523bd7fcd49413037 Mon Sep 17 00:00:00 2001
From: clc5q <clc5q@git.zephyr-software.com>
Date: Sat, 6 Jun 2015 04:18:53 +0000
Subject: [PATCH] Emit DEADREGS annotations for resolved indirect jumps.

Former-commit-id: 1c2b02d8290b13d8c30ce04bc7d97d61f4ca7755
---
 src/base/SMPInstr.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/base/SMPInstr.cpp b/src/base/SMPInstr.cpp
index 85da0945..e248d7b1 100644
--- a/src/base/SMPInstr.cpp
+++ b/src/base/SMPInstr.cpp
@@ -10568,6 +10568,8 @@ void SMPInstr::EmitTypeAnnotations(bool UseFP, bool AllocSeen, bool NeedsFrame,
 #else
 	bool CallInst = ((CALL == DataFlowType) || this->IsTailCall() || this->IsCondTailCall());
 #endif
+	bool IndirJumpInst = (INDIR_JUMP == DataFlowType);
+	bool IndirJumpAnalyzed = IndirJumpInst && (!this->GetBlock()->GetFunc()->HasUnresolvedIndirectJumps());
 	bool NumericDEFs = this->AllDefsNumeric();  // all DEFs are NUMERIC or CODEPTR
 	bool ProfiledDEFs = this->AnyDefsProfiled();  // Some DEFs come from the profiler
 	bool UnusedMetadata = this->AllDefMetadataUnused();
@@ -10897,7 +10899,7 @@ void SMPInstr::EmitTypeAnnotations(bool UseFP, bool AllocSeen, bool NeedsFrame,
 	//  in telling mmStrata about these constants.
 	// Likewise, we can tell mmStrata if a MemDest is an
 	//  non-directly-accessed child object.
-	if (SDTInstrumentation || NoWarnFlag || CallInst) {
+	if (SDTInstrumentation || NoWarnFlag || CallInst || IndirJumpAnalyzed) {
 		if (this->DeadRegsBitmap.any()) {
 			// Optimize by informing mmStrata of dead registers. It can avoid saving
 			//  and restoring dead state. This is particularly important for EFLAGS,
@@ -10906,6 +10908,14 @@ void SMPInstr::EmitTypeAnnotations(bool UseFP, bool AllocSeen, bool NeedsFrame,
 				(unsigned long) addr, this->GetSize());
 			this->PrintDeadRegs(AnnotFile);
 			SMP_fprintf(AnnotFile, " %s \n", disasm);
+			if (IndirJumpAnalyzed && (!this->DeadRegsBitmap[MD_FLAGS_REG])) {
+				// Unusual case: Switch table has live flags into cases.
+				SMP_msg("INFO: IndirJump at %x has live flags register: Successor blocks: ", this->GetAddr());
+				for (list<SMPBasicBlock *>::iterator SuccIter = this->GetBlock()->GetFirstSucc(); SuccIter != this->GetBlock()->GetLastSucc(); ++SuccIter) {
+					SMP_msg("%x ", (*SuccIter)->GetFirstAddr());
+				}
+				SMP_msg("\n");
+			}
 		}
 		int ChildOffset, ChildSize;
 		if (MemDest && ProfInfo->GetMemoryAccessInfo()->ComputeNonDirectAccessRegion(addr,
-- 
GitLab