简体   繁体   中英

Is O3 a fixed optimization sequence? And how to change frame-pointer value in LLVM IR?

I use the following command to figure out the sequence of clang O3,

$ opt -enable-new-pm=0 -O3 -debug-pass=Arguments input.ll

and I get a very long optimization sequence.

Is that sequence same for all of code? Or O3 can change the order according to the source code?

And, I found that if I use -O0 flag to generate IR file, the attributes may be like this,

attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-pr    otector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-    features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

we can see the value of frame-pointer = all , and I think that may let the code slow. ( It will be turned to none by using O3 flag)

How can I change this value by opt command?

thanks a lot.

Yes, optimization sequence is the same for all inputs. But note that opt 's -O3 may not be the same as clang 's -O3.

As for disabling the frame pointer, you can remove it

  • with -fomit-frame-pointer when generating LLVM IR with clang
  • with -frame-pointer=none when optimizing LLVM IR with opt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM