opt passes

Hello,

I am developing now a compiler, based on llvm infrastructure, so I am building my own sequence of llvm passes with some adjustable options.

I can’t find really clear info about some cases, so maybe you can help, and write:

  1. Why I should always delete attributes before applying optimizations with opt command? With attributes specified no optimization can be applied.

Where I can get real benefit from:

  1. Constant Hoisting

-only when we have some large reusable constants in program?

  1. argpomotion
  • this option does not always replace all my args by reerence with values, when I specify it.

You definitely shouldn’t delete attributes in general. Does your attribute set include optnone? -Hal

Oh, yes…strange
attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }

How this can be avoided? it is always so after clang -s -emit-llvm

This is because clang defaults to -O0, and in that mode, does not produce IR that is intended to be optimized. You probably want to do: clang -S -emit-llvm -O3 -mllvm -disable-llvm-optzns to get out the unoptimized IR. -Hal

Great,

thank you for your help!