简体   繁体   English

O3 是一个固定的优化序列吗? 以及如何更改 LLVM IR 中的帧指针值?

[英]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,我用下面的命令找出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?还是O3可以根据源码改顺序?

And, I found that if I use -O0 flag to generate IR file, the attributes may be like this,而且,我发现如果我使用-O0标志来生成 IR 文件,属性可能是这样的,

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.我们可以看到frame-pointer = all的值,我认为这可能会让代码变慢。 ( It will be turned to none by using O3 flag) (使用O3标志会变成none

How can I change this value by opt command?如何通过opt命令更改此值?

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.但请注意opt的 -O3 可能与clang的 -O3 不同。

As for disabling the frame pointer, you can remove it至于禁用帧指针,您可以将其删除

  • with -fomit-frame-pointer when generating LLVM IR with clang使用-fomit-frame-pointer使用clang生成 LLVM IR 时
  • with -frame-pointer=none when optimizing LLVM IR with opt使用opt优化 LLVM IR 时使用-frame-pointer=none

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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