簡體   English   中英

O3 是一個固定的優化序列嗎? 以及如何更改 LLVM IR 中的幀指針值?

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

我用下面的命令找出clang O3的順序,

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

我得到了一個很長的優化序列。

所有代碼的順序是否相同? 還是O3可以根據源碼改順序?

而且,我發現如果我使用-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" }

我們可以看到frame-pointer = all的值,我認為這可能會讓代碼變慢。 (使用O3標志會變成none

如何通過opt命令更改此值?

多謝。

是的,所有輸入的優化序列都相同。 但請注意opt的 -O3 可能與clang的 -O3 不同。

至於禁用幀指針,您可以將其刪除

  • 使用-fomit-frame-pointer使用clang生成 LLVM IR 時
  • 使用opt優化 LLVM IR 時使用-frame-pointer=none

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM