Intel® ISA Extensions
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.
1093 Discussions

question about hardware performance counter

songlinhai
Beginner
250 Views
Hi,

I am trying to use hardware performance counter to track which branch firefox is taking during execution. The event I am using is TAKEN sub-event in BR_INST_RETIRED. And the tool I am using is Linux perf.

In firefox, there is a piece of code like

if(flag){
..
}else{
..
}

After compiling, the related binary codes looks like:

cmp 0x0, flag
je <========================here


jmp




By loading a special web-page, only if branch is executed. But from the perf report, I find the "je " also causes BR_INST_RETIRED TAKEN event. I have add some fprintf into both if and else branch, and I am pretty sure that only if branch is executed.

So this problem is caused by "skid"? or some other reasons causing this problem? I can get which instruction causedBR_INST_RETIRED TAKEN from hardware performance counter, right?

Thanks a lot!

0 Kudos
2 Replies
jimdempseyatthecove
Honored Contributor III
250 Views
Do you see any counts (e.g. INST_RETIRED) inside either/both sections of the if block?
If the entry into one of the sections is infrequent (e.g. once) you might not catch a count.

Jim Dempsey
0 Kudos
songlinhai
Beginner
250 Views
Hi Jim,
I can seeINST_RETIRED in the if branch, and noINST_RETIRED in the else branch. This is reasonable, since only if branch is executed.
But in my experiment, I can see "je " instruction cause TAKEN BRAN_INST_RETIRED. Does this show that the else branch will be executed? Actually else branch is not executed.
Thanks a lot!
Linhai
0 Kudos
Reply