Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions callgrind/fn.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@

#define N_INITIAL_FN_ARRAY_SIZE 10071

static fn_array current_fn_active;
/* The active function array. Defined here but declared in global.h so the
* hot-path accessor CLG_(get_fn_entry) can be inlined. */
fn_array CLG_(current_fn_active);
#define current_fn_active CLG_(current_fn_active)

/* x86_64 defines 4 variants. */
#define MAX_RESOLVE_ADDRS 4
Expand Down Expand Up @@ -783,12 +786,6 @@ fn_node* CLG_(get_fn_node)(BB* bb)
* levels should be separated.
*/

UInt* CLG_(get_fn_entry)(Int n)
{
CLG_ASSERT(n < current_fn_active.size);
return current_fn_active.array + n;
}

void CLG_(init_fn_array)(fn_array* a)
{
Int i;
Expand Down
18 changes: 17 additions & 1 deletion callgrind/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,12 @@ void CLG_(init_fn_array)(fn_array*);
void CLG_(copy_current_fn_array)(fn_array* dst);
fn_array* CLG_(get_current_fn_array)(void);
void CLG_(set_current_fn_array)(fn_array*);
UInt* CLG_(get_fn_entry)(Int n);

/* The active function array (function number -> active count). This is on
* the per-BB hot path (setup_bbcc, get_cxt, ...), so the accessor is inlined
* (see CLG_(get_fn_entry) below) to avoid a cross-TU function call for what
* is a single array index. */
extern fn_array CLG_(current_fn_active);

void CLG_(init_obj_table)(void);
obj_node* CLG_(get_obj_node)(DebugInfo* si);
Expand Down Expand Up @@ -853,6 +858,17 @@ extern ULong* CLG_(cost_base);
#define CLG_ASSERT(cond) tl_assert(cond);
#endif

/* Inlined hot-path accessor for the active function array. Defined after
* CLG_ASSERT so the assertion is available. Called once per basic block from
* setup_bbcc() (and from get_cxt/push_cxt), previously as an out-of-line
* cross-TU call in fn.c. */
static __inline__
UInt* CLG_(get_fn_entry)(Int n)
{
CLG_ASSERT(n < CLG_(current_fn_active).size);
return CLG_(current_fn_active).array + n;
}

/* from debug.c */
void CLG_(print_bbno)(void);
void CLG_(print_context)(void);
Expand Down
Loading