From a6416237d1549860c8ddede81a940cbcec8ba2dd Mon Sep 17 00:00:00 2001
From: clc5q <clc5q@git.zephyr-software.com>
Date: Tue, 19 Jan 2016 02:28:03 +0000
Subject: [PATCH] Expand IBT annotations for hell node case of unreachable
 blocks linked to unresolved indirect jumps; fix SMPInstr::Dump() for the
 marker instruction to avoid calls to IRDB/beaEngine.

Former-commit-id: 38b401b99a8fd379bad975e4aa0b65d58bd3633f
---
 src/base/SMPFunction.cpp |  4 ++++
 src/base/SMPInstr.cpp    | 10 ++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp
index 689be030..e83219f9 100644
--- a/src/base/SMPFunction.cpp
+++ b/src/base/SMPFunction.cpp
@@ -6610,6 +6610,10 @@ void SMPFunction::SetLinks(void) {
 					// Mark CurrBlock as now being reachable, along with the blocks it dominates.
 					CurrBlock->DepthFirstMark();
 					++BlockIter;
+
+					// Block could be IBTarget and thus actually be reachable. Cover our bases by emitting an IBT annotation.
+					SMPInstr *FirstInst = (*(CurrBlock->GetFirstInst()));
+					global_STARS_program->PrintUnknownCodeXref(CurrBlock->GetFirstAddr(), FirstInst->GetSize());
 				}
 				changed = true;
 			} // end if (processed) ... else ...
diff --git a/src/base/SMPInstr.cpp b/src/base/SMPInstr.cpp
index 57ce2ea4..7effb673 100644
--- a/src/base/SMPInstr.cpp
+++ b/src/base/SMPInstr.cpp
@@ -2137,8 +2137,14 @@ void SMPInstr::PrintOperands(void) const {
 
 // Complete DEBUG printing.
 void SMPInstr::Dump(void) {
-	SMP_msg("%llx %zd SMPitype: %d SPOffset: %lld %s\n", (unsigned long long) this->GetAddr(), this->GetSize(), (int) this->type, 
-			(long long) this->GetStackPtrOffset(), DisAsmText.GetDisAsm(this->GetAddr(), this->IsMarkerInst()));
+	if (this->IsMarkerInst()) {
+		SMP_msg("%llx 1 SMPitype: %d SPOffset: %lld fnop\n", (unsigned long long) this->GetAddr(), (int) this->type,
+			(long long) this->GetStackPtrOffset());
+	}
+	else {
+		SMP_msg("%llx %zd SMPitype: %d SPOffset: %lld %s\n", (unsigned long long) this->GetAddr(), this->GetSize(), (int) this->type,
+			(long long) this->GetStackPtrOffset(), DisAsmText.GetDisAsm(this->GetAddr(), false));
+	}
 #if STARS_DUMP_FG_INFO
 	SMP_msg("USEs: ");
 	if (NULL == this->GetBlock()) { // during early improvement of disasm
-- 
GitLab