Amit Prakash
Amit Prakash

Reputation: 1221

what optimization passes are done for -O4 in clang?

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?

Upvotes: 5

Views: 6682

Answers (2)

moobag
moobag

Reputation: 199

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.

Upvotes: 9

Mārtiņš Možeiko
Mārtiņš Možeiko

Reputation: 12927

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).

Upvotes: 9

Related Questions