<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi,<br>
<br>
I am using the profiling feature of LLVM 3.1. Mostly, it works well,
but seems to be wrong in a few cases. For example, I have found that
the number of times a function executed is reported as less than the
number of times that the basic block calling this function executed
(the difference was about 25x!). I am copying out the exact
functions below. The relevant parts are in bold font:<br>
<br>
<b>------------</b><br>
<b>SOURCE :<br>
------------</b><br>
<br>
//accumulate error at a given edge sample point (round to nearest
integral point)<br>
<b>inline void SampleEdgePoint(float xf, float yf, const FlexImage8u
&EdgeMap, int &error, int &samplePoints)<br>
{<br>
int x = int(xf + 0.5f), y = int(yf + 0.5f);<br>
if((x >= 0) && (x < EdgeMap.Width())
&& (y >= 0) && (y < EdgeMap.Height()))
//check image bounds<br>
{ int e = 255 -
EdgeMap(x,y);
//get value from image map and compute difference<br>
error += (e *
e);
//sum squared error values<br>
samplePoints++;
//count points sampled<br>
}<br>
}</b><br>
<br>
//Generate Samples for points along the non-joint edges of the
cylinder<br>
<b>void ImageMeasurements::EdgeError(const ProjectedCylinder
&ProjCyl, const FlexImage8u &EdgeMap, float &error,
int &samplePoints)</b><br>
{<br>
int ErrorSSD = 0;<br>
const Point &p1 = ProjCyl.mPts[0];<br>
Point
s1;
//get direction vector of side 1 of the 2D cylinder projection<br>
s1.Set(ProjCyl.mPts[1].x - p1.x, ProjCyl.mPts[1].y - p1.y);<br>
int n1 = max((int)(mag(s1) / mStep + 0.5),
4); //compute
number of points sampled (sample at least 4)<br>
float d1 = 1.0f /
(float)n1++;
//get fraction of side length per sample<br>
<br>
const Point &p2 = ProjCyl.mPts[2];<br>
Point
s2;
//repeat for side 2 of cylinder<br>
s2.Set(ProjCyl.mPts[3].x - p2.x, ProjCyl.mPts[3].y - p2.y);<br>
int n2 = max((int)(mag(s2) / mStep + 0.5), 4);<br>
float d2 = 1.0f / (float)n2++;<br>
<br>
float delta = 0;<br>
for(int i = 0; i < n1;
i++)
//generate sample points along each side of cylinder projection<br>
{ float x = p1.x + delta * s1.x;<br>
float y = p1.y + delta * s1.y;<br>
<b>SampleEdgePoint(x, y, EdgeMap, ErrorSSD,
samplePoints); </b> //accumulate error at
computed edge points on side 1<br>
delta += d1;<br>
}<br>
delta = 0;<br>
for(int i = 0; i < n2; i++)<br>
{ float x = p2.x + delta * s2.x;<br>
float y = p2.y + delta * s2.y;<br>
<b>SampleEdgePoint(x, y, EdgeMap, ErrorSSD,
samplePoints);</b> //accumulate error at
comptued edge points on side 2<br>
delta += d2;<br>
}<br>
error += (float)ErrorSSD / (255.0f * 255.0f);<br>
}<br>
<br>
<b>---------------------------</b><br>
<b>Call instructions in IR:<br>
---------------------------<br>
<br>
invoke void @_Z15SampleEdgePointffRK9FlexImageIhLi1EERiS3_(float
%109, float %110, %class.FlexImage* %111, i32* %ErrorSSD, i32*
%112)<br>
to label %113 unwind label %124<br>
<br>
invoke void @_Z15SampleEdgePointffRK9FlexImageIhLi1EERiS3_(float
%150, float %151, %class.FlexImage* %152, i32* %ErrorSSD, i32*
%153)<br>
to label %154 unwind label %124</b><br>
<br>
<br>
Thanks.<br>
-Apala<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>