Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9228935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:26:55+00:00 2026-06-18T05:26:55+00:00

I’m using these commands to compile the code below in order to collect edge/blocks

  • 0

I’m using these commands to compile the code below in order to collect
edge/blocks profiling in trunk-llvm:

clang -emit-llvm -c sort.c -o sort.bc
opt -insert-edge-profiling sort.bc -o sort_prof.bc
clang sort_prof.bc -lprofile_rt -L/llvms/lib -o sort_prof

then I run the program and display the profiling information using
llvm-prof sort_prof.bc, and the result is:

===-------------------------------------------------------------------------===
Function execution frequencies:

 ##   Frequency
  1. 4.3e+05/708539 main
  2. 2.8e+05/708539 quickSort

  NOTE: 2 functions were never executed!
.....

My question is regarding the execution frequencies. Does make any
sense main executing 4.3e+05 times?
Why so? The code I’m compiling is below.

###################### sort.c ########################
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

const int MAX = 1000000;

void swap(int* a, int* b) {
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

int partition(int vec[], int left, int right) {
  int i, j;

  i = left;
  for (j = left + 1; j <= right; ++j) {
    if (vec[j] < vec[left]) {
      ++i;
      swap(&vec[i], &vec[j]);
    }
  }
  swap(&vec[left], &vec[i]);

  return i;
}

void quickSort(int vec[], int left, int right) {
  int r;

  if (right > left) {
    r = partition(vec, left, right);
    quickSort(vec, left, r - 1);
    quickSort(vec, r + 1, right);
  }
}

int main(void) {

        int vet[MAX], i=0;

        srand(time(NULL));

        for (i=0; i<MAX; i++) {
                vet[i] = rand() % 654321;
        }

        quickSort(vet, 0, MAX-1);

        for (i=0; i<MAX; i++) {
                if ((rand() % 7) > 2) {
                        printf("Num$[%d] = %d\n", i, vet[i]);
                }
                else if ((rand() % 4) > 2) {
                        printf("Num@[%d] = %d\n", i, vet[i]);
                }
                else if ((rand() % 2) > 1) {
                        printf("Num#[%d] = %d\n", i, vet[i]);
                }
        }

        return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:26:57+00:00Added an answer on June 18, 2026 at 5:26 am

    The problem was that I was passing to llvm-prof the bitcode file with instrumentation, the correct is to use the original file (without instrumentation):

    llvm-prof sort.bc
    

    another problem related to llvm-prof is that it’s rounding the function/block execution frequency due to scientific notation. I’ve submitted a patch to llvm for correcting that.

    Another tip is llvm-prof per default shows only the top 20 most executed basic blocks and it doesn’t provide the user any means to change that. I’ve submitted another patch that add a command line parameter enabling the user to set how many basic blocks he/she wants in the output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am using JSon response to parse title,date content and thumbnail images and place
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.