git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/3] Add a lot of dummy returns to avoid warnings with NO_NORETURN

From
AKAndi Kleen <ak@linux.intel.com>
Date
Jun 21, 2011, 00:24 UTC
Message-ID
<20110621002448.GB700@alboin.amr.corp.intel.com>
In-Reply-To
<20110620224619.GB695@elie>
Show 5 quoted lines
> Anyway, thanks for writing these patches.  I'm happy to see git get
> faster.  As a side question, do you know if gcc provides a way to
> print output about what profile-driven optimizations were especially
> compelling, so they could help people think about how to reorganize
> code to improve the non profile-driven builds, too?

Generally gcc has no idea how much difference an optimization makes. It would need to run the code for that, but it doesn't.

That's generally only possible for JITs.

For some optimizations (basic block reordering) you could get the same benefit with __builtin_expect.

But based on my own experience with __builtin_expect in other projects I strongly recommend to not use it manually: people tend to use it everywhere eventually and they often get it wrong. Humans are quite bad at deciding such things. Also code behaviour changes over time and then the annotations often become outdated.

[e.g. the kernel has a special profiler for builtin_expects -- aka unlikely -- which checks the manual annotation against the true runtime behaviour and the failure rate of manual annotation is quite spectacular]

In addition there are various optimizations in gcc where I am not aware of a manual annotation possibility (like register allocation). The data from profile feedback is used in quite a lot of places all over the compiler.

-Andi
Previous: Jonathan NiederNext: Jonathan Nieder
Message 11 of 20 in “Add option to disable NORETURN”
  1. 1/3 Add option to disable NORETURNAndi Kleen, Jun 19, 2011
  2. 2/3 Add a lot of dummy returns to avoid warnings with NO_NORETURNAndi Kleen, Jun 19, 2011
  3. Junio C HamanoJun 20, 2011
  4. Andi KleenJun 20, 2011
  5. Junio C HamanoJun 20, 2011
  6. Andi KleenJun 20, 2011
  7. Jonathan NiederJun 20, 2011
  8. Andi KleenJun 20, 2011
  9. Jonathan NiederJun 20, 2011
  10. Jonathan NiederJun 20, 2011
  11. Andi KleenJun 21, 2011
  12. Jonathan NiederJun 21, 2011
  13. Junio C HamanoJun 20, 2011
  14. Andi KleenJun 21, 2011
  15. Junio C HamanoJun 20, 2011
  16. Andi KleenJun 20, 2011
  17. Junio C HamanoJun 20, 2011
  18. Andi KleenJun 20, 2011
  19. Junio C HamanoJun 21, 2011
  20. 3/3 Add profile feedback build to git v2Andi Kleen, Jun 19, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.