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

  • Home
  • SEARCH
  • 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 8916173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:10:07+00:00 2026-06-15T05:10:07+00:00

In this question I will focus on Visual Studio 2012 and GCC 4.7 On

  • 0

In this question I will focus on Visual Studio 2012 and GCC 4.7

On the one hand, profile-guided compilation optimizes branch prediction by instrumenting the code at run-time, and then using this information during a second compilation. On the other hand, many compilers provide extensions to hint to the compiler which branch will most-likely be taken: GCC provides __builtin_expect and Visual Studio provides __assume.

Is there a way to extract the profile-guided information (of either compiler) so as to be able to rewrite the code using both compiler extensions? The goal would be to provide an “optimized” source code for people willing to recompile their own version of the binary.

  • 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-15T05:10:10+00:00Added an answer on June 15, 2026 at 5:10 am

    You can extract this information using gcov.

    Compile the sources like:

    gcc -ftest-coverage -fprofile-arcs x.c
    

    Run the executable

    ./a.out
    

    Run gcov -b on a source file. The option -b tells it to generate branch probability information.

    gcov -b x.c
    

    gcov will create text file x.c.gcov, which will contain the required information, here’s a sample:

            -:    5:int
    function foo called 1 returned 100% blocks executed 100%
            1:    6:foo (unsigned int N)
            -:    7:{
            1:    8:  int i, s = 0;
            -:    9:
        10001:   10:  for (i = 0; i < N; ++i)
    branch  0 taken 99%
    branch  1 taken 1% (fallthrough)
            -:   11:    {
        10000:   12:      if ((rand () % 100) < 30)
    call    0 returned 100%
    branch  1 taken 30% (fallthrough)
    branch  2 taken 70%
         3027:   13:        s++;
            -:   14:      else
         6973:   15:        s--;
            -:   16:    }
            -:   17:
            1:   18:  return s;
            -:   19:}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

well, i think this is a very common question but my question will focus
This question will be a little longer and I am sorry for that :)
This question will be short and sweet. I know an instruction can occur between
( Late edit: This question will hopefully be obsolete when Java 7 comes, because
Sorry if this question will sound too chaotic, feel free to edit it. I
My guess is that this question will fall under the category of duh, but,
I guess this question will sound familiar, but I am yet another programmer baffled
I know this question will be closed because I studied many example of this
I hope this question will not be rejected as there is no code. But
This is confusing me, so this question will probably be confusing. I have a

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.