what optimization passes are done for -O4 in clang?
Asked Answered
S

2

5

We are trying to implement a jit compiler whose performance is supposed to be same as doing it with clang -o4. Is there a place where I could easily get the list of optimization passes invoked by clang with -o4 is specified?

Second answered 17/12, 2012 at 23:42 Comment(0)
D
9

As far as I know -O4 means same thing as -O3 + enabled LTO (Link Time Optimization). See the folloing code fragments:

Also see here:

You can produce bitcode files from clang using -emit-llvm or -flto, or the -O4 flag which is synonymous with -O3 -flto.

For optimizations used with -O3 flag see this PassManagerBuilder.cpp file (look for OptLevel variable - it will have value 3).

Disgraceful answered 18/12, 2012 at 0:26 Comment(1)
Note: This is no longer correct. The manual now explicitly states that " -O4 and higher: Currently equivalent to -O3". People who are using O4 and think they're doing LTO, aren't.Glaydsglaze
M
9

Note that as of LLVM version 5.1 -O4 no longer implies link time optimization. If you want that you need to pass -flto. See Xcode 5 Release Notes.

Malchy answered 10/3, 2014 at 22:24 Comment(1)
Please use LLVM versions when talking about LLVM, not Apple LLVM versions - LLVM is currently at 3.5, so 5.1 is non-existent.Sensitive

© 2022 - 2024 — McMap. All rights reserved.