Hi, 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: *------------* *SOURCE : ------------* //accumulate error at a given edge sample point (round to nearest integral point) *inline void SampleEdgePoint(float xf, float yf, const FlexImage8u &EdgeMap, int &error, int &samplePoints) { int x = int(xf + 0.5f), y = int(yf + 0.5f); if((x >= 0) && (x < EdgeMap.Width()) && (y >= 0) && (y < EdgeMap.Height())) //check image bounds { int e = 255 - EdgeMap(x,y); //get value from image map and compute difference error += (e * e); //sum squared error values samplePoints++; //count points sampled } }* //Generate Samples for points along the non-joint edges of the cylinder *void ImageMeasurements::EdgeError(const ProjectedCylinder &ProjCyl, const FlexImage8u &EdgeMap, float &error, int &samplePoints)* { int ErrorSSD = 0; const Point &p1 = ProjCyl.mPts[0]; Point s1; //get direction vector of side 1 of the 2D cylinder projection s1.Set(ProjCyl.mPts[1].x - p1.x, ProjCyl.mPts[1].y - p1.y); int n1 = max((int)(mag(s1) / mStep + 0.5), 4); //compute number of points sampled (sample at least 4) float d1 = 1.0f / (float)n1++; //get fraction of side length per sample const Point &p2 = ProjCyl.mPts[2]; Point s2; //repeat for side 2 of cylinder s2.Set(ProjCyl.mPts[3].x - p2.x, ProjCyl.mPts[3].y - p2.y); int n2 = max((int)(mag(s2) / mStep + 0.5), 4); float d2 = 1.0f / (float)n2++; float delta = 0; for(int i = 0; i < n1; i++) //generate sample points along each side of cylinder projection { float x = p1.x + delta * s1.x; float y = p1.y + delta * s1.y; *SampleEdgePoint(x, y, EdgeMap, ErrorSSD, samplePoints); * //accumulate error at computed edge points on side 1 delta += d1; } delta = 0; for(int i = 0; i < n2; i++) { float x = p2.x + delta * s2.x; float y = p2.y + delta * s2.y; *SampleEdgePoint(x, y, EdgeMap, ErrorSSD, samplePoints);* //accumulate error at comptued edge points on side 2 delta += d2; } error += (float)ErrorSSD / (255.0f * 255.0f); } *---------------------------* *Call instructions in IR: --------------------------- invoke void @_Z15SampleEdgePointffRK9FlexImageIhLi1EERiS3_(float %109, float %110, %class.FlexImage* %111, i32* %ErrorSSD, i32* %112) to label %113 unwind label %124 invoke void @_Z15SampleEdgePointffRK9FlexImageIhLi1EERiS3_(float %150, float %151, %class.FlexImage* %152, i32* %ErrorSSD, i32* %153) to label %154 unwind label %124* Thanks. -Apala -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121213/67600707/attachment.html>