Callgrind: use jmpkind from VEX for side exits.

To detect calls and returns, Callgrind's heuristic
starts with using the jumpkind got from VEX for
a control flow change instruction. However, for
side exits, it always assumed a (conditional) jump,
which holds true for x86, but e.g. not for ARM.

This fixes Callgrind to use the jumpkind found
by VEX for all exits, which should help making
Callgrind work for ARM. It also moves the check
whether a boring jump is actually a fall-through
to instrumentation time. This changes (fixes) the
result for indirect jumps to the next instruction,
which should not be classified as fall-through
(anyway, this case is probably very rare).

This patch introduces an own enum for jump kinds
in Callgrind. This is less confusing than misusing
the VEX jump kind type, as Callgrinds wants
to distinguish BB fall-throughs from real jumps
(which both are Ijk_Boring in VEX).
Also, setup_bbcc now stores separately whether the
jump kind is conditional or not.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12269 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/callgrind/global.h b/callgrind/global.h
index 5f06917..63f6e10 100644
--- a/callgrind/global.h
+++ b/callgrind/global.h
@@ -229,6 +229,18 @@
 typedef ULong* FullCost; /* Simulator + User */
 
 
+/* The types of control flow changes that can happen between
+ * execution of two BBs in a thread.
+ */
+typedef enum {
+  jk_None = 0,   /* no explicit change by a guest instruction */
+  jk_Jump,       /* regular jump */
+  jk_Call,
+  jk_Return,
+  jk_CondJump    /* conditional jump taken (only used as jCC type) */
+} ClgJumpKind;
+
+
 /* JmpCall cost center
  * for subroutine call (from->bb->jmp_addr => to->bb->addr)
  *
@@ -248,11 +260,9 @@
  * After updating, <last> is set to current event counters. Thus,
  * events are not counted twice for recursive calls (TODO: True?)
  */
-#define JmpNone (Ijk_Boring+30)
-#define JmpCond (Ijk_Boring+31)
 
 struct _jCC {
-  Int  jmpkind;     /* JmpCall, JmpBoring, JmpCond */
+  ClgJumpKind jmpkind; /* jk_Call, jk_Jump, jk_CondJump */
   jCC* next_hash;   /* for hash entry chain */
   jCC* next_from;   /* next JCC from a BBCC */
   BBCC *from, *to;  /* call arc from/to this BBCC */
@@ -276,13 +286,14 @@
 };
 
 
+
 /*
- * Info for a conditional jump in a basic block
+ * Info for a side exit in a BB
  */
 typedef struct _CJmpInfo CJmpInfo;
 struct _CJmpInfo {
-    UInt instr; /* instruction index in this basic block */
-    Bool skip;   /* Cond.Jumps to next instruction should be ignored */
+  UInt instr;          /* instruction index for BB.instr array */
+  ClgJumpKind jmpkind; /* jump kind when leaving BB at this side exit */
 };
 
 
@@ -319,11 +330,10 @@
   BBCC*      last_bbcc;  /* Temporary: Cached for faster access (LRU) */
 
   /* filled by CLG_(instrument) if not seen before */
-  UInt       cjmp_count;  /* number of conditional exits */
+  UInt       cjmp_count;  /* number of side exits */
   CJmpInfo*  jmp;         /* array of info for condition jumps,
 			   * allocated directly after this struct */
-  Int        jmpkind;    /* remember jump kind of final exit */
-  Bool       cjmp_inverted; /* condition of last cond.jump can be inverted by VEX */
+  Bool       cjmp_inverted; /* is last side exit actually fall through? */
 
   UInt       instr_len;
   UInt       cost_count;
@@ -357,12 +367,12 @@
 
 
 /*
- * Info for a conditional jump in a basic block
+ * Cost info for a side exits from a BB
  */
 typedef struct _JmpData JmpData;
 struct _JmpData {
     ULong ecounter; /* number of times the BB was left at this exit */
-    jCC*  jcc_list;  /* JCCs for Cond.Jumps from this exit */
+    jCC*  jcc_list; /* JCCs used for this exit */
 };